Solved

Hi there Delphers - Q on OpenRegKeyEx

Posted on 1999-01-24
2
149 Views
Last Modified: 2010-04-06
I am writing a program in which needs to open a key in the registry - I can't make head nor tail of the Delphi help file though! It's a long key with many subdir's!

i.e HKEY_CLASSES_ROOT\CLSID\{very-long-name-here!}\etc.

I then wish to delete the values in that key

Can anyone help me?

Cheers

Jim
0
Comment
Question by:Rudolf
2 Comments
 
LVL 5

Accepted Solution

by:
heathprovost earned 100 total points
Comment Utility
How about this....





procedure DeleteKeyValues(TheRootKey: HKEY; KeyName: String);
var
  Reg: TRegistry;
  Values: TStringList;
  I: integer;
begin
  Reg := TRegistry.Create;
  Values := TStringList.Create;
  try
    With Reg do
    begin
      RootKey := TheRootKey;
      OpenKey(KeyName, False);
      GetValueNames(Values);
      for I := 0 to Values.Count - 1 do
        DeleteValue(Values[I]);
      CloseKey;
    end;
  finally
    Values.Free;
    Reg.Free;
  end;
end;




You would call it in your case like this:

DeleteKeyValues(HKEY_CLASSES_ROOT, 'CLSID\{very-long-name-here!}\etc.')


Hope this helps


Heath
0
 

Author Comment

by:Rudolf
Comment Utility
Cheers Heath - I will try it out when I get home but it looks good! Hope I graded you ok - difficult to grade you when I can't check it out!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now