Solved

Hi there Delphers - Q on OpenRegKeyEx

Posted on 1999-01-24
2
151 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
ID: 1363095
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
ID: 1363096
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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