Solved

RegDeleteKey with RegQuery !!!

Posted on 1997-03-22
2
529 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
[X]
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
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…

734 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