Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to delete a registry item?

Posted on 1999-07-16
14
Medium Priority
?
260 Views
Last Modified: 2010-04-06
Hello,
For examples, a STRING TYPE registry item in the following path:
'HKEY_LOCAL_MACHINE\SOFTWARE\MyName\'
The name of then string item to be deleted is: 'version'
How can I just delete the item 'version', but NOT the whole path (ie ....\SOFTWARE\MyName)?

Thanks
0
Comment
Question by:yingkit
[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
14 Comments
 
LVL 3

Expert Comment

by:markshiffer
ID: 1389048
Try TRegistry.DeleteKey(const key : string);
0
 
LVL 2

Expert Comment

by:kotik
ID: 1389049
Why don't you use TRegistry class and call DeleteKey?


0
 
LVL 17

Accepted Solution

by:
inthe earned 40 total points
ID: 1389050
hi,
you need to use DeleteValue not Deletekey.

procedure TForm1.Button1Click(Sender: TObject);
var
  reg: TRegistry;
begin
  reg := TRegistry.Create;
  reg.RootKey := HKEY_LOCAL_MACHINE;
  reg.LazyWrite := false;
  reg.OpenKey('SOFTWARE\MyName',false);
  reg.DeleteValue('version');
  reg.CloseKey;
  reg.free;
end;

Regards Barry
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:BlackDeath
ID: 1389051
inthe - why do i think that

with TRegistry.Create do begin
  try
    ...
  finally
    Free;
  end;
end;

is better than

var
  reg: TRegistry;

reg := TRegistry.Create;
...
reg.Free;

?

;-)

BlackDeath.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389052
mmm dunno why ? maybe you still drunk  <S>

no i was just showing the function deletvalue but blackdeatth is right ,dont forget to put these registry functions in a try , finally loop to stop any errors in case the keys dot exist or something.
Cheers BD   :-)
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1389053
of corze i'm still pissed -

btw - do u know the bruce's philosophers song (m.p.)?

it's my hymn...#%-P

BlackBoozer.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389054
>>the bruce's philosophers song (m.p.)?

tell me more, what is this song?
maybe i know it not sure..
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1389055
monty python - live @the hollywood bowl:

"immanuel kant was a real pissant
who was very rarely stable
heidegger, heidegger was a boozy beggar
who could drink u under the table
david hume could outconsume
wittgenstein & hegel
& rene descartes was a drunken fart
i drink therefor i am

yes socrates himsel is particularly missed
a lovely little thinker but a bugger when he's pissed"

etc.

;-P

BlackHic.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389056
hahahah that rings bells :-)
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1389057
-"your american beer is a little bit like making love in a canoe"

-"why is that?"

c'mon, barry - gimme the answer...

<*>

BlindHack.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389058
it's f**king close to water   :-))))




0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1389059
aaargh - himme:

i mixed up while writing the verse down from memory.
here's the correct (& full) version:



   Immanuel Kant was a real pissant
        who was very rarely stable.
   Heidegger, Heidegger was a boozy beggar
        who could think you under the table.
   David Hume could out consume
        Wilhelm Friedrich Hegel, (Other versions: "Shoppenhauer and Hegel")
   And Wittgenstein was a beery swine
        who was just as sloshed as Schlegel.

   There's nothing Nietzsche couldn't teach ya
       'bout the raisin' of the wrist.
   Socrates himself was permanently pissed.

   John Stewart Mill, of his own free will,
        after half a pint of shandy was particularly ill.
   Plato, they say, could stick it away,
        'alf a crate of whiskey every day!
   Aristotle, Aristotle was a bugger for the bottle,
        and Hobbes was fond of his Dram.
   And Rene Descartes was a drunken fart:
        "I drink, therefore I am."

   Yes, Socrates himself is particularly missed;
   A lovely little thinker, but a bugger when he's pissed.
 
?-o

AmnesiacDeath.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1389060
yeah, man - u've got it!

(our comments seemed 2 have overcrossed)

BD.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389061
:-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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