问题
I am getting some Icons from the Shell32.dll. Althought some of the icons don't appear to be available, and I can't understand why.
I am getting the icon by loading the library by calling:
[DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string Library);
and then getting the icon by calling:
[DllImport("User32.dll")]
public static extern IntPtr LoadImage(IntPtr ptr, int intId, uint intType, int iconWidth, int iconHeight, int loadIcon);
I send in the icon index of the icon that I am getting, which works fine for icpons such as the Open Folder Icon (index 5) and LogIn icon (Index 45) but when i try and get icons at index (71, 73, 127, etc. etc.) I get the following exception: Win32 handle that was passed to Icon is not valid or is the wrong type
I was wondering if anyone knew why this was happening? and why some of the icons are accessible and others appear not.
Thanks
回答1:
why some of the icons are accessible and others appear not.
Because the icons are not part of the public contract of Shell32.dll.
You shouldn't rely on loading icons from Shell32.dll anyway. Raymond Chen explains why, though I can't find the article.
来源:https://stackoverflow.com/questions/949196/loading-icons-from-shell32-dll-win32-handle-is-not-valid-or-is-the-wrong-type