Home > Archive > Smartphone Developer Forum > January 2006 > SizeofResource problem on WM 5.0 based Smartphone
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 |
SizeofResource problem on WM 5.0 based Smartphone
|
|
| jbuergel@gmail.com 2006-01-24, 7:07 pm |
| In my setup DLL, I need to open up a binary resource and use it. The
following code works fine on a WM 5.0 PocketPC, but fails on
Smartphone. Specifically, the FindResource() and LoadResource() calls
work fine, but SizeofResource() fails with GetLastError() returns error
6 (ERROR_INVALID_HANDLE). I have no idea why this wouldn't work.
hInst here is the instance handle passed in to DllMain:
hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDB_BINARY_DATA),
RT_RCDATA);
if (NULL == hResInfo) {
return FALSE;
}
hResData = LoadResource(hInst, hResInfo);
if (NULL == hResData) {
return FALSE;
}
// get the size of the cert and a pointer to the buffer
size = SizeofResource(hInst, hResInfo);
| |
| Norman Diamond 2006-01-24, 7:07 pm |
| In my experience, SizeofResource is telling the truth about its failure
because FindResource doesn't work. How did LoadResource get to work after
FindResource didn't work, I can't guess.
<jbuergel@gmail.com> wrote in message
news:1138142340.300919.178810@g43g2000cwa.googlegroups.com...
> In my setup DLL, I need to open up a binary resource and use it. The
> following code works fine on a WM 5.0 PocketPC, but fails on
> Smartphone. Specifically, the FindResource() and LoadResource() calls
> work fine, but SizeofResource() fails with GetLastError() returns error
> 6 (ERROR_INVALID_HANDLE). I have no idea why this wouldn't work.
> hInst here is the instance handle passed in to DllMain:
>
> hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDB_BINARY_DATA),
> RT_RCDATA);
> if (NULL == hResInfo) {
> return FALSE;
> }
> hResData = LoadResource(hInst, hResInfo);
> if (NULL == hResData) {
> return FALSE;
> }
> // get the size of the cert and a pointer to the buffer
> size = SizeofResource(hInst, hResInfo);
>
| |
| Norman Diamond 2006-01-25, 4:15 am |
| OK, sorry, my experience was due to calling FindResource with RT_STRING.
You're calling FindResource with RT_RCDATA so who knows if maybe
FindResource is supposed to work in your case.
"Norman Diamond" <ndiamond@community.nospam> wrote in message
news:%23rtUcYUIGHA.648@TK2MSFTNGP14.phx.gbl...
> In my experience, SizeofResource is telling the truth about its failure
> because FindResource doesn't work. How did LoadResource get to work after
> FindResource didn't work, I can't guess.
>
> <jbuergel@gmail.com> wrote in message
> news:1138142340.300919.178810@g43g2000cwa.googlegroups.com...
>
| |
| Michael J. Salamone 2006-01-26, 7:59 am |
| My guess is the resources aren't properly built in your Smartphone
application. Have you tried opening the .exe file in VS 2005 to view them?
Verify that they are there.
If you look at the shared source in
\WINCE500\private\winceos\coreos\nk\kern
el\resource.c, you'll see
SizeofResource simply calls SetLastError(ERROR_INVALID_HANDLE) if the size
of the resource is 0 - nothing to do with the hInst. It doesn't even use
the hInst!
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
<jbuergel@gmail.com> wrote in message
news:1138142340.300919.178810@g43g2000cwa.googlegroups.com...
> In my setup DLL, I need to open up a binary resource and use it. The
> following code works fine on a WM 5.0 PocketPC, but fails on
> Smartphone. Specifically, the FindResource() and LoadResource() calls
> work fine, but SizeofResource() fails with GetLastError() returns error
> 6 (ERROR_INVALID_HANDLE). I have no idea why this wouldn't work.
> hInst here is the instance handle passed in to DllMain:
>
> hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDB_BINARY_DATA),
> RT_RCDATA);
> if (NULL == hResInfo) {
> return FALSE;
> }
> hResData = LoadResource(hInst, hResInfo);
> if (NULL == hResData) {
> return FALSE;
> }
> // get the size of the cert and a pointer to the buffer
> size = SizeofResource(hInst, hResInfo);
>
|
|
|
|
|