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,251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

733 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