Solved

RegDeleteKey with RegQuery !!!

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now