Solved

Easy question

Posted on 2001-06-08
3
1,122 Views
Last Modified: 2008-02-01
I wonder if someone could give me an example of RegDeleteValue.  I know the syntax, but seeing an acutal example
would be very helpful.

Say you want to delete HKCU\key\value what would the the RegDeleteValue paramiters be?

0
Comment
Question by:PastorDwayne
  • 2
3 Comments
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6169972
Try something like this:
If you want to delete a value in the key you spevified then do this:

  HKEY hregkey; // Declaring a key pointer for usage.
  long res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HKCU\\key", 0, KEY_ALL_ACCESS, &hregkey);
  if (res == 0)
  {
    RegDeleteValue(hregkey, "value") //Now let's delete the item value
  }
  RegCloseKey(hregkey);

If you want to delete the key you spevified then do this:

  RegDeleteKey(HKEY_LOCAL_MACHINE, "HKCU\\key\\Value");

Cheers,

Alan
0
 
LVL 5

Accepted Solution

by:
alanwhincup earned 50 total points
ID: 6169978
If you want to delete a value and check if its been deleted succesfully then replace:

RegDeleteValue(hregkey, "value")

with

if (RegDeleteValue(hregkey, "value") == ERROR_SUCCESS)
{
 // Do Whatever
}

in the above code.
0
 

Author Comment

by:PastorDwayne
ID: 6169981
Thanks, I think this should do it...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

760 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

20 Experts available now in Live!

Get 1:1 Help Now