Solved

RegQueryKey and RegDeleteKey (4)

Posted on 1997-05-07
1
2,008 Views
Last Modified: 2012-08-13
Hello,

I wrote already for the same question but I never receipt response.

How to delete a key in the registry found by RegQueryValue.

Ex : in the key HKEY_CURRENT_USER\\Software\\xyz , the value of reg (by example ) is 32568
I want delete the key HKEY\\LOCAL_MACHINE\\Software\\32568

I'm want delete key that is value !!!!! Thanks. The value is the Key !!!!



How do I do ?

Thanks
0
Comment
Question by:puce020497
1 Comment
 
LVL 1

Accepted Solution

by:
shappir earned 50 total points
ID: 1163347
First thing first, there is no Win32 API function called RegQueryKey ! You either mean RegQueryInfoKey
or RegQueryValueEx. As to your question, if I understand correctly you want to delete a key called 32568
that is a subkey of HKEY_LOCAL_MACHINE\Software. What you should do is open HKEY_LOCAL_MACHINE\Software using RegOpenKeyEx and then use RegDeleteKey:

HKEY hKey;
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,                  TEXT("Software"), 0,                  KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS ) {
  RegDeleteKey(hKey, TEXT("32568"));
  RegCloseKey(hKey);
}

Note that if 32568 has subkeys this will not work on all versions of Windows NT. If you must also support these platforms you must write a recursive decent and delete routine. If 32568 is actually a value use RegDeleteValue instead of RegDeleteKey.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

829 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