eVC++ DLL and CE 5.0 SDK

M

MS-Dev

Hello,

I apologize if this has been asked and answered...

I created a dll in eVC++ 4.0 (SP4) for use as an icon library for a CF
application I'm working on (VB). There are 3 icon resources in the dll
(100,101, and 102). I'm using LoadLibrary and LoadIcon to grab different
icons based on events in the app and using them in a call to a notification
class created based on an article I read on MSDN (I'm hoping to eventually
look into getting the Icon property in the OpenNetCF NotifyIcon to cooperate
with me). This all works great in the VS.NET standard emulator. The icons
load and unload, I can see the HInstance, and HIcon in the autos window when
I add a breakpoint, etc, etc...

Now when I load the same application in an SDK emulator for a CE 5.0 build,
everything is always null. I'm guessing it's the emulator build, or some
incompatibility between my dll and CE 5.0 or something, but before I go down
that path does anyone else have any ideas?

TIA,

Laslo
 
S

Sergey Bogdanov

Please, check the Marshal.GetLastWin32Error value after LoadLibrary call
(I suppose the value will be 193 - ERROR_BAD_EXE_FORMAT). If it's right,
then compile your eVC application for ARM4 architecture.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
M

MS-Dev

Sergey,

Thanks for your response. I added this to the form load event...
Dim resDll As String = "NotifyIconLib.dll"
Dim resHandle As IntPtr = LoadLibrary(resDll)
MsgBox(Marshal.GetLastWin32Error)
Dim hIcon As IntPtr
hIcon = LoadIcon(resHandle, "#100")
NotifyIcon.Add(hIcon)

The MsgBox always returns 0. The NotifyIconLib.dll is added to my project
with a build action of content. If I change it to embedded and change

Dim resDll As String = "NotifyIconLib.dll"
to
Dim resDll As String = "MyApplication.NotifyIconLib.dll"

the result is the same. Any other ideas?

Also, my target beyond the emulator is x86 so should I still compile for
ARM4?

TIA,

Laslo
 
S

Sergey Bogdanov

What LoadLibrary declaration do you have? It must have SetLastError
equals to 'true', it will indicate that the callee will call SetLastError:

[DllImport("coredll", EntryPoint="LoadLibraryW", SetLastError=true)]
static extern IntPtr LoadLibrary(string lpszLib);

For emulator leave x86, for your PocketPC use ARMV4 when compile your DLL.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
M

MS-Dev

Sergey,

Thanks again for the help! You were right, I changed that in my declaration
(oops) and I get error 126, ERR_MOD_NOT_FOUND. I read an article on google
yesterday about a guy who had the exact same problem but he was trying to
use a VC++ 6 dll when he got this error.

http://groups-beta.google.com/group..._doneTitle=Back+to+Search&&d#863ebc07dea88491

So I'll do some research here and see what I find. Again, thanks for the
help.

Regards,
Laslo


Sergey Bogdanov said:
What LoadLibrary declaration do you have? It must have SetLastError equals
to 'true', it will indicate that the callee will call SetLastError:

[DllImport("coredll", EntryPoint="LoadLibraryW", SetLastError=true)]
static extern IntPtr LoadLibrary(string lpszLib);

For emulator leave x86, for your PocketPC use ARMV4 when compile your DLL.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

MS-Dev said:
Sergey,

Thanks for your response. I added this to the form load event...
Dim resDll As String = "NotifyIconLib.dll"
Dim resHandle As IntPtr = LoadLibrary(resDll)
MsgBox(Marshal.GetLastWin32Error)
Dim hIcon As IntPtr
hIcon = LoadIcon(resHandle, "#100")
NotifyIcon.Add(hIcon)

The MsgBox always returns 0. The NotifyIconLib.dll is added to my
project with a build action of content. If I change it to embedded and
change

Dim resDll As String = "NotifyIconLib.dll"
to
Dim resDll As String = "MyApplication.NotifyIconLib.dll"

the result is the same. Any other ideas?

Also, my target beyond the emulator is x86 so should I still compile for
ARM4?

TIA,

Laslo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top