I'm trying to build a sample project for windows mobile (pre-windows phone 7). I've created a Win32 device project in VS 2008 and i have the windows mobile SDKs installed. I replace the main function stub with the following sample code, but it fails to build with two linker errors. I'm guessing this is some sort of configuration error or build settings error but i don't know where to look. I've built very few C++ projects and i'm not familiar with the different options. Can anyone suggest anything that might help?
Taken from: Auto-launching CF apps with the HKLM\Init Registry Key
extern "C" DWORD WaitForAPIReady(DWORD, DWORD);
extern "C" BOOL IsAPIReady(DWORD hAPI);
int _tmain(int argc, _TCHAR* argv[])
{
// quick sanity check - HKLM\Init will send in our order number
if(argc == 0) return 0;
BOOL success = FALSE;
// wait for window manager - that should be enough for us
#if _WIN32_WCE > 0x500
success = (WaitForAPIReady(SH_WMGR, 5000) == WAIT_OBJECT_0);
#else
int i = 0;
while((! IsAPIReady(SH_WMGR)) && (i++ < 50))
{
Sleep(100);
}
success = (i < 50);
#endif
if(success)
{
int launchCode = _ttoi(argv[1]);
SignalStarted(launchCode);
}
else
{
RETAILMSG(TRUE, (_T("CFInitGate timed out - SH_WMGR was not ready after 5 seconds\r\n")));
}
return 0;
}
And the linker errors i see:
- Error 1 error LNK2019: unresolved external symbol WaitForAPIReady referenced in function wmain LaunchGate.obj LaunchGate
- Error 2 fatal error LNK1120: 1 unresolved externals Windows Mobile 6 Standard SDK LaunchGate
According to the WaitForAPIReady documentation i need to include kfuncs.h
and according to the IsAPIReady documentation i should use windev.h
. When i #include "kfuncs.h"
i开发者_开发知识库 get no syntax errors, but the linker still complains. When i #include "windev.h"
i get file not found.
Any ideas? thanks, brian
Don't declare them as extern "C"
. Declare thus:
extern WINAPI DWORD WaitForAPIReady(DWORD, DWORD);
extern WINAPI BOOL IsAPIReady(DWORD hAPI);
It's a different calling convention - stdcall vs. cdecl, thus different name mangling rules.
Do an dumpbin /EXPORTS of the dll and see how it is mangled. if you see an bunch of odd symbols, it's an c++ created dll and you should declare them as seva answered, else you should declare them as you do.
Why are you declaring the functions yourself instead of #include'ing kfuncs.h?
精彩评论