I currently use the WM_GETICON
message in a C# Windows application to get the icon associated with a hWnd
, but it won't get me the icon for ApplicationFrameHost
(Windows Store Apps) processes (which makes sense, since it hides the actual application).
Here is the code I currently use, which works for "normal" apps:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
public static IntPtr GetAppIcon(IntPtr hwnd)
{
var iconHandle = SendMessage(hwnd, WM_GETICON, ICON_BIG, 0);
if (iconHandle == IntPtr.Zero)
iconHandle = SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0);
if (iconHandle == IntPtr.Zero)
iconHandle = SendMessage(hwnd, WM_GETICON, ICON_SMALL2, 0);
return iconHandle;
}
Getting the ApplicationFrameHost.exe
icon won't help me here. It seems there is such an icon though, since a) I can see it in the task bar, and b) I can also see it in Task Manager.
How can I get this icon?