Solved

I keep getting the error "The procedure entry point RegDeleteKeyExW could not be located in the dynamic link library ADVAPI32.dll"

Posted on 2006-06-23
5
4,223 Views
Last Modified: 2012-05-05
Hi
I have a program written in C++ using Visual Studio 2005.
At some point in my code I would like to call the function RegDeleteKey to delete a specific registry key.

My code is as simple as this:

LONG MyClass::deleteAKey(CString path)
{
    LONG lRet;

    // open the key
    if ( ERROR_SUCCESS !=  RegOpenKeyEx ( HKEY_LOCAL_MACHINE, path, 0, _sam, &_hKey))
    {
          //Could not open the registry key
          return -1;
    }
    else
         lRet = RegDeleteKeyEx(_hKey, path, KEY_WOW64_64KEY, 0);

    return lRet;
}

All compiles and links fine.  But when I try to run my program, I immediately get the error message, "The procedure entry point RegDeleteKeyExW could not be located in the dynamic link library ADVAPI32.dll".  Now I wonder what could be wrong.

At the top of my .cpp file, I have also added the line:
#pragma comment(lib, "Advapi32.lib")

but nothing helps.

I'm guessing it has to do with name mangling but I'm not sure how to go about fixing this.  I'm not sure...just a guess.
Can anyone help?

Thanks so much
0
Comment
Question by:zarrona
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16973821
'RegDeleteKeyEx()' is mapped to 'RegDeleteKeyExW()' when UNICODE is #defined, yet that entry point should be there. What OS are you rinning that under? The minimum requirement is

Client
  Requires Windows Vista or Windows XP Professional x64 Edition.
Server
  Requires Windows Server "Longhorn" or Windows Server 2003 SP1.


see http://msdn.microsoft.com/library/en-us/sysinfo/base/regdeletekeyex.asp

BTW, have you tried

         lRet = RegDeleteKeyExA(_hKey, path, KEY_WOW64_64KEY, 0);

to explicitly call the ANSI counterpart?
0
 

Author Comment

by:zarrona
ID: 16974386
hi jkr,

Yes, Unicode is defined in my project and I understand that is why the "W" if found in "RegDeleteKeyExW()".
And I had already tried explicitly using the ANSI form RegDeleteKeyExA(hKey, "somepath" KEY_WOW64_64KEY, 0)...but that still made no difference.  I even tried using KEY_WOW64_32KEY as the 3rd paramater. :-(...no hope.

I'm developing and running my program on a Windows XP Professioal x64 Edition too.  So I'm guessing my machine is concidered a "client" right?...since I"m not trying to develope on a server.

I'm wondering do I have to load the library  "Advapi32.lib" in a different way rather than just adding the line

#pragma comment(lib, "Advapi32.lib")

at the top of my cpp file.  Or maybe make some changes to the Project Properties to add a dll or .lib or change something in the Linker section.

Another thought....I just noticed under the MSDN site the function RegDeleteKey().  Appears a bit different. I wonder what could be the big difference other than the parameters.

thanks

0
 

Author Comment

by:zarrona
ID: 16986718
Problem solved....

I just used the RegDeleteKey() function and that gave me no problems while running my program.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 17258159
PAQed with points refunded (500)

CetusMOD
Community Support Moderator
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question