Well I’ve just spent ages trying to figure out how to get the window icon (the icon displayed in the title bar at the far left) for an external program window from a VB.NET app – tried using GetClassInfo, GetClassInfoEx, GetClassLong, GetWindowLong and a few other APIs… only to find that you can simply use SendMessage to send the WM_GETICON message and it returns a handle to the icon – and this works perfectly *for most windows* (I’ll explain in a moment). So for anyone else wanting to do the same thing in the future, here’s a basic vb.net example of how to get the window icon from a window.
The reason I say it only works for most windows and not all windows is because there are a couple of applications that seem to ignore the WM_GETICON message (Lotus Notes 7 and Notepad were the two examples I encountered) so it might be worth checking to see if the handle you got from SendMessage is null and if it is then calling GetClassLong and passing GCL_HICON as the second parameter. Using GetClassLong in that way works for Notepad but as of yet I have not been unable to find anything that gets the icon from a Lotus Notes 7 window!
Hope that helps someone out as I know there is currently very little on the internet when you try and find out how to do this from .NET code.