NO

Author Topic: which lib must been included for work with registry?  (Read 8316 times)

sp00n

  • Guest
which lib must been included for work with registry?
« 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.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: which lib must been included for work with registry?
« Reply #1 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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

sp00n

  • Guest
Re: which lib must been included for work with registry?
« Reply #2 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'

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: which lib must been included for work with registry?
« Reply #3 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).
/Pelle

sp00n

  • Guest
Re: which lib must been included for work with registry?
« Reply #4 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?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: which lib must been included for work with registry?
« Reply #5 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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

sp00n

  • Guest
Re: which lib must been included for work with registry?
« Reply #6 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:)

AlDef

  • Guest
Re: which lib must been included for work with registry?
« Reply #7 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)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: which lib must been included for work with registry?
« Reply #8 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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

AlDef

  • Guest
Re: which lib must been included for work with registry?
« Reply #9 on: May 18, 2007, 08:29:11 AM »
Many thanks. This solved the linker issue.

Cheers, A_