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,178 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now