Solved

RegQueryKey and RegDeleteKey (4)

Posted on 1997-05-07
1
1,990 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

810 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