getProcAddressW errors when use visual studio2005 and windows mobile SDK to debug windows CE project

StackOverflow https://stackoverflow.com/questions/18400510

  •  26-06-2022
  •  | 
  •  

سؤال

I am using Visual Studio 2005 and Windows Mobile 6 Professional Device SDK to debug a Windows CE project (copied from a Windows project ). I use active sync to connect PC and Win CE device. Then I create a new Windows CE project (copied from Windows project, but create using windows mobile 6 professional device SDK as platform. vc++, smart device, console app ).

When I build the windows CE project, there are some errors:

Error   1   error C2664: 'GetProcAddressW' : cannot convert parameter 2 from 'const char [21]' to 'LPCWSTR' xxxxx.cpp   42  

It occurred after I used LoadLibrary(_T(xx.dll)); then I used GetProcAddress(handle,"functionName");

If I change it to use GetProcAddress(handle, _T("functionName") ); this error dispears. But new error

LINK: error LNK2019: unresolved external symbol __imp_Function2 
    referenced in function wmain    xxxx.obj

occured, Function2 is from another DLL project(both for windows and windows CE).

I don't know if I describe the problem clear, but I want to ask are there any way to make the source code that is both for Windows and windows CE when in the source code some functions are from different DLLs ?

Any answers are appriciated!

هل كانت مفيدة؟

المحلول

The first compiler error is somewhat self explanatory. get "W" at the end of GetProcAddressW means that the method is the wide character API (as opposed to GetProcAddressA, which is the ASCII version). Windows CE only exports the wide character versions of APIs. That means that you have to pass in a wide-character string. You used a TCHAR macro when you used _T, which makes the enclosed string a wide character literal, and the error goes away.

The same code should work fine on big Windows (for any recent version anyway), provided that you #define UNICODE (which is probably already on) and #include "tchar.h" which I think you since _T compiles. You could explicitly call GetProcAddressW instead of just GetProcAddress (which should be #defined to the wide version if UNICODE is defined).

The source linker error you see isn't clear. I'm guessing __imp_Function2 is a function pointer that you're trying to assign with the GetProcAddress call? Basically the linker isn't finding it, but the root cause isn't clear with the info you've provided.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top