Fix: Gorev cubugu tüy simgesi giderildi, AppUserModelID ve Win32 WM_SETICON tam entegrasyonu

This commit is contained in:
LilDosto 2026-11-04 04:20:25 +03:00
parent c023d461df
commit 45bcba6aee
12 changed files with 84 additions and 6 deletions

Binary file not shown.

BIN
app.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 353 KiB

View file

@ -43,8 +43,8 @@ Source: "{#SourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
Source: "app.ico"; DestDir: "{app}"; Flags: ignoreversion
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\app.ico"
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico"; AppUserModelID: "LDSoftware.LDUninstaller"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\app.ico"; AppUserModelID: "LDSoftware.LDUninstaller"
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

View file

@ -9,9 +9,14 @@ namespace LDUninstaller.Launcher
{
internal static class Program
{
[DllImport("shell32.dll", SetLastError = true)]
private static extern int SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
[STAThread]
static void Main(string[] args)
{
try { SetCurrentProcessExplicitAppUserModelID("LDSoftware.LDUninstaller"); } catch { }
ApplicationConfiguration.Initialize();
// 1. Architecture check

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 353 KiB

View file

@ -1,13 +1,24 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
namespace LDUninstaller.UI
{
public partial class App : Application
{
[DllImport("shell32.dll", SetLastError = true)]
private static extern int SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
protected override void OnStartup(StartupEventArgs e)
{
try
{
// Unify taskbar grouping with shortcuts and ensure correct icon binding
SetCurrentProcessExplicitAppUserModelID("LDSoftware.LDUninstaller");
}
catch { }
base.OnStartup(e);
string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "trace.log");

View file

@ -4,10 +4,11 @@
Title="Toplu Kaldırma Sihirbazı - LD Uninstaller"
Height="620" Width="850"
WindowStartupLocation="CenterOwner"
ShowInTaskbar="False"
Background="{StaticResource BrushBgDark}"
Foreground="{StaticResource BrushTextPrimary}"
FontFamily="Segoe UI"
Icon="pack://application:,,,/Resources/app.ico"
Icon="pack://application:,,,/LDUninstaller.UI;component/Resources/app.ico"
BorderBrush="{StaticResource BrushBorder}"
BorderThickness="1">

View file

@ -4,10 +4,11 @@
Title="Kalıntı Temizleme Motoru - LD Uninstaller"
Height="580" Width="920"
WindowStartupLocation="CenterOwner"
ShowInTaskbar="False"
Background="{StaticResource BrushBgDark}"
Foreground="{StaticResource BrushTextPrimary}"
FontFamily="Segoe UI"
Icon="pack://application:,,,/Resources/app.ico"
Icon="pack://application:,,,/LDUninstaller.UI;component/Resources/app.ico"
BorderBrush="{StaticResource BrushBorder}"
BorderThickness="1">

View file

@ -9,7 +9,7 @@
Background="{StaticResource BrushBgDark}"
Foreground="{StaticResource BrushTextPrimary}"
FontFamily="Segoe UI"
Icon="pack://application:,,,/Resources/app.ico"
Icon="pack://application:,,,/LDUninstaller.UI;component/Resources/app.ico"
BorderBrush="{StaticResource BrushBorder}"
BorderThickness="1">

View file

@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using LDUninstaller.Core.Bulk;
using LDUninstaller.Core.Discovery;
using LDUninstaller.Core.InfoAdders;
@ -52,9 +54,67 @@ namespace LDUninstaller.UI
miniTreeMap.OnItemSelected += SelectAppFromTreemap;
fullTreeMap.OnItemSelected += SelectAppFromTreemap;
TraceLog("2. MainWindow ctor finished");
TraceLog($"2. MainWindow ctor finished, Icon={this.Icon}");
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
SetNativeWindowIcon();
}
private void SetNativeWindowIcon()
{
try
{
var helper = new WindowInteropHelper(this);
IntPtr hwnd = helper.Handle;
if (hwnd == IntPtr.Zero) return;
try
{
var uri = new Uri("pack://application:,,,/LDUninstaller.UI;component/Resources/app.ico", UriKind.Absolute);
this.Icon = System.Windows.Media.Imaging.BitmapFrame.Create(uri);
}
catch { }
string icoPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "app.ico");
IntPtr hIconBig = IntPtr.Zero;
IntPtr hIconSmall = IntPtr.Zero;
if (File.Exists(icoPath))
{
hIconBig = LoadImage(IntPtr.Zero, icoPath, 1, 32, 32, 0x00000010);
hIconSmall = LoadImage(IntPtr.Zero, icoPath, 1, 16, 16, 0x00000010);
}
if (hIconBig == IntPtr.Zero || hIconSmall == IntPtr.Zero)
{
string exe = Process.GetCurrentProcess().MainModule?.FileName ?? "";
ExtractIconEx(exe, 0, out IntPtr hL, out IntPtr hS, 1);
if (hIconBig == IntPtr.Zero) hIconBig = hL;
if (hIconSmall == IntPtr.Zero) hIconSmall = hS;
}
if (hIconBig != IntPtr.Zero)
SendMessage(hwnd, 0x0080, (IntPtr)1, hIconBig);
if (hIconSmall != IntPtr.Zero)
SendMessage(hwnd, 0x0080, (IntPtr)0, hIconSmall);
}
catch { }
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad);
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
private static extern int ExtractIconEx(string lpszFile, int nIconIndex, out IntPtr phiconLarge, out IntPtr phiconSmall, int nIcons);
private static void TraceLog(string msg)
{
try

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 353 KiB

BIN
test_bmp.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB