Pelles C forum

C language => Beginner questions => Topic started by: sp00n on March 30, 2007, 10:01:11 AM

Title: which lib must been included for work with registry?
Post 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.
Title: Re: which lib must been included for work with registry?
Post by: 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.
Title: Re: which lib must been included for work with registry?
Post by: sp00n on March 30, 2007, 10:30:25 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'
Title: Re: which lib must been included for work with registry?
Post by: Pelle on March 30, 2007, 12:26:18 PM
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).
Title: Re: which lib must been included for work with registry?
Post by: sp00n on March 30, 2007, 01:38:52 PM
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?
Title: Re: which lib must been included for work with registry?
Post by: 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.
Title: Re: which lib must been included for work with registry?
Post by: sp00n on April 01, 2007, 11:41:48 AM
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:)
Title: Re: which lib must been included for work with registry?
Post by: AlDef on May 15, 2007, 06:57:33 PM
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)
Title: Re: which lib must been included for work with registry?
Post by: frankie on May 15, 2007, 10:10:39 PM
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.
Title: Re: which lib must been included for work with registry?
Post by: AlDef on May 18, 2007, 08:29:11 AM
Many thanks. This solved the linker issue.

Cheers, A_