which lib must been included for work with registry?

Started by sp00n, March 30, 2007, 10:01:11 AM

Previous topic - Next topic

sp00n

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.

frankie

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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

sp00n

Quote from: frankie on March 30, 2007, 10:14:14 AM
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:
Quote
#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",&reg_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:
Quote
POLINK: error: Unresolved external symbol 'RegCreateKeyW'.
POLINK: error: Unresolved external symbol 'RegQueryValueW'.
POLINK: error: Unresolved external symbol 'RegSetValueW'

Pelle

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).
/Pelle

sp00n

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?

frankie

For poketPC you must use the extended functions RegCreateKeyEx, RegQueryValueEx and RegSetValueEx.
Normal calls doesn't seem to exist.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

sp00n

Quote from: frankie on March 30, 2007, 04:32:22 PM
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:)

AlDef

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)

frankie

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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

AlDef

Many thanks. This solved the linker issue.

Cheers, A_