If you're using a global mouse hook, I'm assuming the window handle that of a window in another application If that's the case, most handles are application-specific. Retreiving a handle via a SendMessage call will get an application-specific handle. The HICON from the SHGetFileInfo should work.
Handles are usually just a pointer into the application's memory--which generally isn't accessible by other applications. You have to marshal the handle from one process to another. I don't know of any Platform SDK functions that would marshal an icon handle from one process to another. I think you'd have to spawn a thread in the source process to get the icon data and communicate it back to the other process. Not a trivial process.
Returning icon handle to VCSharp
Nikhil Pereira
If you're using a global mouse hook, I'm assuming the window handle that of a window in another application If that's the case, most handles are application-specific. Retreiving a handle via a SendMessage call will get an application-specific handle. The HICON from the SHGetFileInfo should work.
Handles are usually just a pointer into the application's memory--which generally isn't accessible by other applications. You have to marshal the handle from one process to another. I don't know of any Platform SDK functions that would marshal an icon handle from one process to another. I think you'd have to spawn a thread in the source process to get the icon data and communicate it back to the other process. Not a trivial process.
Glenn Peterson
Do Hoang Ha
Labi
[
DllImport("apihooks.dll", CharSet = CharSet.Auto,CallingConvention =
CallingConvention.StdCall)] public static extern IntPtr GetWindowIcon(IntPtr hwnd, IntPtr hicon);