Hi,All
I am using theuser32.dll API toload theimages from a dll resource file.
When the programruns, an exception turns up: A generic error occurred in GDI+.
I already search the web and this Forum.
There is a question verylike whatI met, but the language islike VBI can'tunderstand it well at
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/662dd6ed-0ec5-4c9b-bba1-0c049b6d3fe2/ Could somebody help me? thanks a lot
The code is as follows:
public static Image LoadImage(int Identifier, string ResourceFile)
{
// Works
IntPtr MyLib = LoadLibrary(ResourceFile);
IntPtr HShell32Image = LoadImage(MyLib, new IntPtr(Identifier), 0, 0, 0, 0);
Image myImage = Image.FromHbitmap(HShell32Image); //------------> exception from here
return myImage;
}
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr LoadImage(IntPtr hinst, IntPtr lpszName, uint uType,
int cxDesired, int cyDesired, uint fuLoad);
[System.Runtime.InteropServices.DllImport("Kernel32.dll")]
public static extern IntPtr LoadLibrary(string lpFileName);
the same problem with Y.tks