I found a software doing what you want to do, so it is possible
http://www.softboy.net/exeico/
I've seen another sample code using a different function to extract an icon from a file, and maybe you want to try it out:
Code:
SHGetFileInfo("c:\\windows\\notepad.exe",0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON);
pDC->DrawIcon(10,10,stFileInfo.hIcon);
Since you've said before that drawing the icon obtained with ExtractIcon() works, but LockResource() or GlobalLock() are always returning NULL, makes me believe that ExtractIcon() doesn't fail, so there's no need to change it.
I have another question though:
Do you use LoadLibrary() to load the module from where you need to copy your icon?
http://msdn.microsoft.com/library/de...gResources.asp
Quote Originally Posted by MSDN
The pointer returned by LockResource is valid until the module containing the resource is unloaded. It is not necessary to unlock resources because the system automatically deletes them when the process that created them terminates.

Do not try to lock a resource by using the handle returned by the FindResource or FindResourceEx function. Such a handle points to random data.
These are the remarks on LockResource() function.

I'm so sorry I couldn't make the time to write a fully functional sample code, but I hope these links will lead you to it.

Best regards,