Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

resource dll LoadLibrary returns error code 193

842 views
Skip to first unread message

xiangp...@hotmail.com

unread,
Dec 23, 2008, 2:29:16 AM12/23/08
to
Hi,

I created a resource only dll under windows mobile 6.0, and I tried to
call LoadLibrary on device emulator, it always return NULL and the
error code from GetLastError is 193 ( is not a valid win32
applicaltion). The system setting for the dll is "WindowsCE (/
SUBSYSTEM:WINDOWSCE)", and the target machine is set to "MachineX86 (/
MACHINE:X86)" or not set. I'm using VS2005. The dll is very simple,
just contains a string ( for test). Any ideas what may be wrong?
Thanks.

Ping

Bruce Eitman [eMVP]

unread,
Dec 23, 2008, 2:18:45 PM12/23/08
to
That error indicates one or more of the following:

1. The dll isn't a built for Windows CE
2. The dll isn't built for the processor family
3. Another dll that the dll needs to load isn't available

--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG http://geekswithblogs.net/bruceeitman

EuroTech Inc.
www.EuroTech.com

<xiangp...@hotmail.com> wrote in message
news:29f45a41-21b0-4cca...@t26g2000prh.googlegroups.com...

Core...@gmail.com

unread,
Dec 23, 2008, 4:39:13 PM12/23/08
to

> 1.  The dll isn't a built for Windows CE
> 2.  The dll isn't built for the processor family
> 3.  Another dll that the dll needs to load isn't available

I seem to remember that I was getting 193 on LoadLibrary() if it
couldn't find the file at all. So perhaps verifying the obvious:
4. If you're not using an explicit path, CE has a specific search path
for LoadLibrary().
5. If you are using an explicit path, remember to escape your
backslashes.
6. Remember there is no current working directory on CE, so its never
included in the search path.

xiangp...@hotmail.com

unread,
Dec 23, 2008, 5:30:50 PM12/23/08
to

I'm sure it can find the dll, cause I open the dll using "fopen" and
it works. Thanks for your reply.

Bruce Eitman [eMVP]

unread,
Dec 23, 2008, 6:50:04 PM12/23/08
to

And another:

7. If a function that is needed isn't in the dll.
This happens if the dll on the system isn't the same as the the one that
was being built when the lib that you linked to was created. It is
sometimes a symptom of using the wrong SDK for your target.

--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG http://geekswithblogs.net/bruceeitman

EuroTech Inc.
www.EuroTech.com

<Core...@gmail.com> wrote in message
news:bd6dc814-e336-4d43...@x16g2000prn.googlegroups.com...


Bruce Eitman [eMVP]

unread,
Dec 23, 2008, 7:12:25 PM12/23/08
to
I just tested those. I get error 126 - The specified module could not be
found. Not 193.

I just added
http://geekswithblogs.net/BruceEitman/archive/2008/12/23/windows-ce-loadlibrary-fails-with-error-code-193.aspx
to my blog to look into this more.

--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG http://geekswithblogs.net/bruceeitman

EuroTech Inc.
www.EuroTech.com

<Core...@gmail.com> wrote in message
news:bd6dc814-e336-4d43...@x16g2000prn.googlegroups.com...

> 1. The dll isn't a built for Windows CE

xiangp...@hotmail.com

unread,
Dec 24, 2008, 12:13:36 AM12/24/08
to
The way I test this is, I deploy resouce.dll to the same folder as
where the main exe is, note, you have to deploy the dll before running
main exe ( I use remote file viewer to verify the dll is in place),
here is my code sample :

HMODULE mod = ::LoadLibrary(_T("CEResource.dll"));
HRESULT r = ::GetLastError();

And GetLastError returns 193 for me.

CEResource.dll is very simple, I used "Win32 Smart Device Project" to
create it as a dll project and put a simple string for testing. I
don't think it relies on other dlls to run. The only reason it's not
working I guess, there's something wrong with platform or
architechture setting. I tried different combinations of "subsystem"
and "target machine" setting, but no luck.

On Dec 23, 4:12 pm, "Bruce Eitman [eMVP]"


<bruce.eitman.nos...@EuroTech.com.nospam> wrote:
> I just tested those.  I get error 126 - The specified module could not be
> found.  Not 193.
>

> I just addedhttp://geekswithblogs.net/BruceEitman/archive/2008/12/23/windows-ce-l...


> to my blog to look into this more.
>
> --
> Bruce Eitman (eMVP)
> Senior Engineer
> Bruce.Eitman AT EuroTech DOT com
> My BLOGhttp://geekswithblogs.net/bruceeitman
>
> EuroTech Inc.www.EuroTech.com
>

> <CoreyS...@gmail.com> wrote in message

Bruce Eitman [eMVP]

unread,
Dec 24, 2008, 10:23:28 AM12/24/08
to
Never call GetLastError() unless there is an error. You could get an error
code for some function called sometime in the past.

--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com

My BLOG http://geekswithblogs.net/bruceeitman

EuroTech Inc.
www.EuroTech.com

<xiangp...@hotmail.com> wrote in message
news:394541cd-45a2-42f7...@i18g2000prf.googlegroups.com...

xiangp...@hotmail.com

unread,
Dec 24, 2008, 1:11:39 PM12/24/08
to
On Dec 24, 7:23 am, "Bruce Eitman [eMVP]"

<bruce.eitman.nos...@EuroTech.com.nospam> wrote:
> Never call GetLastError() unless there is an error.  You could get an error
> code for some function called sometime in the past.
>
> --
> Bruce Eitman (eMVP)
> Senior Engineer
> Bruce.Eitman AT EuroTech DOT com
> My BLOGhttp://geekswithblogs.net/bruceeitman
>
> EuroTech Inc.www.EuroTech.com
>
> <xiangping...@hotmail.com> wrote in message
> > included in the search path.- Hide quoted text -
>
> - Show quoted text -

Yeah, thanks for the tip, the code should be I guess:


HMODULE mod = ::LoadLibrary(_T("CEResource.dll"));

if(mod == NULL)
{
HRESULT r = ::GetLastError();
}

xiangp...@hotmail.com

unread,
Dec 24, 2008, 2:25:40 PM12/24/08
to
The output from 'dumpbin' (only listed header and optional section):

Microsoft (R) COFF/PE Dumper Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file CEResource.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
14C machine (x86)
3 number of sections
49528994 time date stamp Wed Dec 24 11:12:20 2008
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
2102 characteristics
Executable
32 bit word machine
DLL

OPTIONAL HEADER VALUES
10B magic # (PE32)
8.00 linker version
0 size of code
A00 size of initialized data
0 size of uninitialized data
0 entry point
1000 base of code
1000 base of data
10000000 image base (10000000 to 10003FFF)
1000 section alignment
200 file alignment
4.00 operating system version
0.00 image version
5.01 subsystem version
0 Win32 version
4000 size of image
400 size of headers
0 checksum
9 subsystem (Windows CE GUI)
0 DLL characteristics
10000 size of stack reserve
1000 size of stack commit
100000 size of heap reserve
1000 size of heap commit
0 loader flags
10 number of directories
0 [ 0] RVA [size] of Export Directory
0 [ 0] RVA [size] of Import Directory
2000 [ 29B] RVA [size] of Resource Directory
0 [ 0] RVA [size] of Exception Directory
0 [ 0] RVA [size] of Certificates Directory
3000 [ 8] RVA [size] of Base Relocation Directory
1000 [ 1C] RVA [size] of Debug Directory
0 [ 0] RVA [size] of Architecture Directory
0 [ 0] RVA [size] of Global Pointer Directory
0 [ 0] RVA [size] of Thread Storage Directory
0 [ 0] RVA [size] of Load Configuration Directory
0 [ 0] RVA [size] of Bound Import Directory
0 [ 0] RVA [size] of Import Address Table
Directory
0 [ 0] RVA [size] of Delay Import Directory
0 [ 0] RVA [size] of COM Descriptor Directory
0 [ 0] RVA [size] of Reserved Directory

I'm loading the dll on device emulator v2

xiangp...@hotmail.com

unread,
Dec 24, 2008, 3:11:52 PM12/24/08
to
Ok, I finally made it work. Use LoadLibraryEx instead of LoadLibrary.
This is how it works:

::LoadLibraryEx(_T("CEResource.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);

Thanks everyone for help.

Merry Christmas!

0 new messages