I have an icon file name specified arbitrarily as
filename, filename.ico, filename.exe etc
How can I use this function to extract the main icon from the file ?

My attempt was

WORD id;
HICON hc=ExtractAssociatedIcon(0, szfilename, &id);
where szfilename specified tha path to the icon file.

But the icon displayed as an unknown file icon.

If I changed it into
WORD id=0;
HICON hc=ExtractAssociatedIcon(0, szfilename, &id);

then I would get icons with black background (without transparancy)

Any advice please ?

Thank you.