public static BitmapSource GetAppIcon(IntPtr hwnd) { IntPtr hIcon = WI.GetClassLongPtr(hwnd, WI.ICON_SMALL); try { if (hIcon == IntPtr.Zero) { hIcon = WI.SendMessage(hwnd, WindowMessage.GETICON, WI.ICON_SMALL2, 0); } if (hIcon == IntPtr.Zero) { hIcon = WI.SendMessage(hwnd, WindowMessage.GETICON, WI.ICON_BIG, 0); } if (hIcon == IntPtr.Zero) { hIcon = WI.GetClassLongPtr(hwnd, WI.GCL_HICON); } if (hIcon == IntPtr.Zero) { hIcon = WI.GetClassLongPtr(hwnd, WI.GCL_HICONSM); } } catch (Exception ex) { } if (hIcon == IntPtr.Zero) { return(null); } var bs = IconSource(hIcon); return(bs); }
public void Close() { WindowInterop.SendMessage(Hwnd, WindowMessage.CLOSE, 0, 0); }