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
Solved

RegDeleteKey with RegQuery !!!

Posted on 1997-03-22
2
527 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

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…

860 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