The links you provided me with show only how to read an icon from an .ico file, which is not what I need.
I found the following code in MSDN (Q104570) on howw to save an HICON to disk and then read it and so gain an pointer to the icon.
The problem is that it doesn't work. The lpGMem pointer is always NULL.Code:int NEAR _pascal SaveMyIcon( HICON hIcon) { int fh, i, iResult; UINT uiSize; DWORD dwSize; OFSTRUCT of; if (!hIcon) return FALSE; dwSize = GlobalSize(hIcon); lpGMem = GlobalLock(hIcon); fh = OpenFile ("myicon.bin", &of, OF_WRITE | OF_CREATE); if (fh == -1) // If NOT opened successfully. { MessageBox(NULL, "Unable to create file", NULL, MB_OK ); return FALSE; } uiSize = _lwrite(fh, (LPSTR)lpGMem, (UINT)dwSize); _lclose(fh); if (uiSize == -1 || uiSize < (UINT)dwSize) { MessageBox(NULL, "Unable to read file", NULL, MB_OK ); return FALSE; } else // Everything worked, return hGMem. { return (HICON)hGMem; } }
Is it might be because I don't know what type lpGMem is (the article doesn't say). I made it LPTSTR, LPBYTE... and it doesnt work. What sould I do? Is it really not posible to gain a valid pointer from an HICON handle provided by ExtractIcon()?
Please help!




Reply With Quote