Search code examples
visual-studio-2008visual-c++windows-mobile-6

Issue loading DLL for VC++ smart device application


I am creating a simple project with VC++ win32 console application and trying to load a dll file using function “LoadLibrary("D:\SRV\RFIDReader.dll");” and I am able load it this way. But when I try to do the same thing in a Smart Device application its giving me an error while compilation. Error says: “error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [22]' to 'LPCWSTR'”.

The solutions i have already tried are as follows: 1. On using "L" or "_T" or "TEXT" before the String (path of the dll), it compiles but on running the app, LoadLibrary returns NULL. 2. Changing the Character Set in Properties to "Use Multi Byte Character Set" also didnt help.

I am using Visual Studio 2008 and Windows Mobile SDK 6.0. Any idea regarding this issue? I am really new to both VC++ and Windows Mobile.

Thanks in advance


Solution

  • Two issues!!

    1) All Windows CE / Windows Mobile APIs are Unicode. So you need to compile the application for Unicode, and you need to wrap string constants in _T() macros. (Explicit L prefixes are possible by _T() is more robust.)

    2) Windows CE / Windows Mobile devices do not have drive letters, so your path cannot be right.

    So your call should be more like

    LoadLibrary(_T("\SRV\RFIDReader.dll"));