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

Easy question

Posted on 2001-06-08
3
1,146 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

856 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