?
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
Medium Priority
?
4,827 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
4 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

809 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