Solved

RegDeleteKey with RegQuery !!!

Posted on 1997-03-22
2
526 Views
Last Modified: 2013-12-03
Hi

I want to delete value from registry with regDeleteKey.

That value is find by RegQueryValueEx.

EX
LONG retCode4;
HKEY hKey4;
DWORD dwBytes4 = 128;
DWORD dwType4;
unsigned char szBuffer4[17];
retCode4 = RegOpenKeyEx(HKEY_CURRENT_USER,
                                          "SOFTWARE\\mice",
                                          0,
                                          KEY_ALL_ACCESS,
                                          &hKey4);

RegQueryValueEx(hKey4, "Number", 0, &dwType4,
                  szBuffer4, &dwBytes4);

RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\exemple\\szBuffer4");

How do I do ?
Thanks in advance.
0
Comment
Question by:puce020497
2 Comments
 

Accepted Solution

by:
phuene earned 300 total points
ID: 1298691
Hello:
Not sure why you are using RegQueryValue() and RegDeleteKey() to delete a value, here's an example code to delete the value with RegDeleteValue():

HKEY hKey;

RegOpenKeyEx(HKEY_CURRENT_USER,"SOFTWARE\\MySubKey",0,KEY_ALL_ACCESS,&hKey);
RegDeleteValue(hKey,"My Value");
RegCloseKey(hKey);

This is to delete "My Value" from the key HKEY_CURRENT_USER\SOFTWARE\MySubKey
You can change this to whatever you want.  This code assumes no errors, and does not error handle.  Hope this helps,
        Regards,
                PHUENE
0
 

Author Comment

by:puce020497
ID: 1298692
Hi,

Of course I want query value of key for delete after the
key which have the same name(in other directory) found with query.
Thanks for the response.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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