Pelles C forum
C language => Beginner questions => Topic started by: sp00n on March 30, 2007, 10:01:11 AM
-
when I use registry API (functions like RegCreateKey, RegQueryValue etc) I've get an unresolved errors in linker:( In standart API help says that it is in the advapi32.lib and coredll.lib, but it doesn't work.
What is a problem, who know?
P.S. In MS VS2005 all works well.
-
Have you also added the 'advapi32.lib' in the linker stream?
To add from menu open: prject->project_options, select the linker tab then add the advapi32.lib in the object files and library edit box.
-
Have you also added the 'advapi32.lib' in the linker stream?
To add from menu open: prject->project_options, select the linker tab then add the advapi32.lib in the object files and library edit box.
Oh, course I've added it:) If it would work I should not ask about it.
P.S. Project for PocketPC, if you need this info)
some code:
#define UNICODE
...
#include "winreg.h"
...
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
...
if (RegCreateKey(HKEY_LOCAL_MACHINE ,L"SOFTWARE\\Apps\\MicrosoftAplicationInstaller\\Install",®_path)!=ERROR_SUCCESS)
{
MessageBox(NULL,L"OPEN REGISTRY ERROR", L"Error install:", MB_OK|MB_SETFOREGROUND|MB_TOPMOST|MB_APPLMODAL);
return 0;
}
WCHAR regvalue[MAX_PATH] = L"\\program files\\myproject";
long cbValue;
if (RegQueryValue(reg_path,NULL, L"MyProject_PPC.CAB",&cbValue)!=ERROR_SUCCESS)
{
RegSetValue(reg_path,NULL,REG_SZ,regvalue,sizeof(regvalue));
}
...
}
Linker writes me:
POLINK: error: Unresolved external symbol 'RegCreateKeyW'.
POLINK: error: Unresolved external symbol 'RegQueryValueW'.
POLINK: error: Unresolved external symbol 'RegSetValueW'
-
If it is a Pocket PC project, you must use the 'Pocket PC' import libraries - so the correct library is coredll.lib not advapi32.lib (which is for desktop Windows only).
-
i've included both libs - coredll.lib and advapi32.lib it doesn't make any effect (when i've excluded advapi32.lib from project - it doesn't make any effect too) :(
so, may be the library "coredll.lib" didn't build for PocketPC?
-
For poketPC you must use the extended functions RegCreateKeyEx, RegQueryValueEx and RegSetValueEx.
Normal calls doesn't seem to exist.
-
For poketPC you must use the extended functions RegCreateKeyEx, RegQueryValueEx and RegSetValueEx.
Normal calls doesn't seem to exist.
Thanks a lot. It works now:) But in MS VC++ that functions (non-extended) works too. Very interesting:)
-
Hi
Aha, it is always worth going through the old postings: replacing RegOpenKey() by RegCreateKeyEx() solved *this* linker problem.
Is there also an extended version for RAS functions (e.g., RasGetEntryProperties)? Or another function that replaces it? I experience the same issue there.
Kind regards, A_
PS: I have very substantial experience in C++, and I am new to Pelles C (which I need for PocketPC programming)
-
Unfortunately in this case the problem is a buggy ras.h header.
The WinCE routines are misnamed.
Try the attached modified header only for WinCe, some functions are missing, but it should be useful for now.
I hope Pelle will have time to fix.
-
Many thanks. This solved the linker issue.
Cheers, A_