Home > Archive > Smartphone Developer Forum > January 2006 > SHGetFileInfo problem in WM5
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
SHGetFileInfo problem in WM5
|
|
| Scewbedew 2006-01-13, 7:04 pm |
| I have a Smartphone home plugin that presents some program icons on the
screen. The user can launch a program by selecting the icon.
I use SHGetFileInfo like this:
const int iconParms = SHGFI_DISPLAYNAME | SHGFI_SMALLICON |
SHGFI_SYSICONINDEX;
HIMAGELIST hImageList;
TCHAR filename[MAX_PATH] = TEXT("\Windows\Start Menu\Tasks.lnk");
TCHAR * pfilename = filename;
memset(&SHFileInfo, 0, sizeof(SHFILEINFO));
hImageList = (HIMAGELIST)SHGetFileInfo (pfilename,NULL, &SHFileInfo,
sizeof(SHFILEINFO),iconParms);
In Smartphone 2003, it alsways works as expected, i.e. I get an icon index
in the iIcon member of SHFileInfo and the system image list handle in
hImageList.
In Windows Mobile 5, it works as expected if I activate my home screen
manually.
But in WM5, if the home screen is selected when I boot the Smartphone, the
first icon gets "destroyd". All return parameters from SHGetFileInfo seems
to be OK; the displayname is correct and the file attributes are as expected
and the image list handle is valid.
The only missing link is the iIcon index that is 0, and when used I get a
generic folder icon instead of the correct one. When this happens, the icon
in the start menu is also corrupted in the same way, and displays a generic
folder icon!
My application loads 7 icons, and the remaining 6 loads OK every time. If I
swap icons and put some other icon as the first one to load, this icon will
get the problem, and the corresponding icon on the start menu will also be
affected!
So, clearly something happens when I call SHGetFileInfo the very first time
during a boot of the Smartphone; something that ruins the icons that is
accessed.
Is this a know problem? What can I do to get rid of it?
/S
| |
| Scewbedew 2006-01-14, 3:58 am |
| Some additional notes:
I found a SHGetFileInfo description on MSDN (though not the Smartphone SDK
one) that discreetly mentioned that you must call CoInitialize before using
SHGetFileInfo. This is not mentioned in the Smartphone SDK and is not present
in the example code they have.
I tried it, but it made no difference.
So I simply made the call for a dummy icon (path ="Dummy") as the first call
to SHGetFileInfo. Of course I get an error (GetLastError = 25), but since I
never intended to use the icon anyhow, it doesn't matter. Now all my ordinary
icons works as expected, and no destroyd icons in the start menu.
Do someone know if the GetLastError() code really mean something useful? It
isn't described in the SDK as being used by SHGetFileInfo, but obviously
something is stored there. I issue a SetLastError(12345) before the
SHGetFileInfo calls, just to see if it changes it; and it does.
I get 25 in the Dummy call, all the other calls gives 0, 2 or 6 though it's
not at random since the same icon always gets the same return code. When I
get the destoyd-icon-on-first-call thing, the GetLastError() says 0...
/S
|
|
|
|
|