[Win32 ExtractAssociatedIconEx] Try to get main icon identifier

Hi folks,

I have a terrible problem, already struggeling for 2 weeks with it. So I decided to post on a forum. I searched the whole internet for answers. Asked my fellow students. Nobody knew the answer.
Oke, here it comes. In every .exe file there is a resource section which maintains the icons that are contained in the exe. There are often more than just one icon in every .exe stored. Every icon has an unique identifier. Now I try to get the identifier of the icon which is displayed as you see it normally when u view an .exe in your windows viewer for example.

I try to do it this way:
[code]int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)

LPWORD a_ = (LPWORD)malloc(100);
LPWORD b_ = (LPWORD)malloc(100);
char* buffert;
char arr[] = "C:\test.exe";
int buffSize;

*a_ = 0;
*b_ = 0;
buffert = (char*)malloc(10);
memset(buffert, 0, 10);

//wchar_t widearray[100];
//mbstowcs(widearray, narrowarray, 100);
buffSize = (int)strlen(arr) + 1;
gah = (wchar_t*)malloc(sizeof(wchar_t) * buffSize);
MultiByteToWideChar(CP_ACP, 0, arr, buffSize, gah, buffSize);
if(ExtractAssociatedIconEx(0, (LPWSTR)gah, a_, b_) == NULL)
MessageBox(0, _T("fail"),0,0);

itoa(*a_, buffert, 10);
MessageBox(0, (LPWSTR)buffert,0,0);
itoa(*b_, buffert, 10);
MessageBox(0, (LPWSTR)gah,0,0);[/code]

The trouble is with the ExtractAssociatedIcon. It should put the correct identifier in the variabele a_. It does not do this.
With resource hacker I can check if it returns me the right icon identifier. Guess what, it does not work for me. It worked once for me in the past. Don't know why it's not working now. I checked a lot of examples (Which are hard to find) and also the msdn (http://msdn.microsoft.com/en-us/library/ms648067(v=vs.85).aspx) didn't help me further. Very rare problem I guess.
Thank god who can tell me what I'm doing wrong.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!