我有一个启动窗口进程的应用程序。我已成功设法更新窗口图标以及使用Alt + Tab时显示的图标:
public class ProcessLauncher {
...
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hwnd, int message, int wParam, IntPtr lParam);
private const int WM_SETICON = 0x80;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;
public void LaunchProcess() {
var process = new Process();
var startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "C:"
};
process.StartInfo = startInfo;
process.Start();
Thread.Sleep(50);
var icon = Resources.MyIcon;
SendMessage(process.MainWindowHandle, WM_SETICON, ICON_BIG, icon.Handle);
SendMessage(process.MainWindowHandle, WM_SETICON, ICON_SMALL, icon.Handle);
}
...
}
这很好用,但该进程的任务栏图标保持不变。如何更新任务栏图标以匹配我为窗口和Alt + Tab提供的图标?