registry access


procedure craig;
var
  sKey : string;
  reg  : TRegIniFile;
  t: tstrings;
begin

  reg := TRegIniFile.Create( '' );
  reg.RootKey := HKEY_LOCAL_MACHINE;
{  reg.openkey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\',true);}
{  reg.currentkey:='\Software\Microsoft\Windows\CurrentVersion\Uninstall\';}
{  reg.WriteString('Software\Microsoft\Windows\CurrentVersion\Run'
     + sKey + #0,sProgTitle, sCmdLine );}
     {ReadSection(const Section: string; Strings: TStrings);}
{     HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall}
reg.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion\Uninstall\');
      form1.listbox1.items:=t;
{    reg.readSection('\Software\Microsoft\Windows\CurrentVersion\Uninstall\winamp\',form1.listbox1.items);}
{    reg.readsections(t);}
{     reg.readsections(t);}
{     form1.listbox1.items:=t;}
  reg.Free;
end;


Must admit, i try like hell before i ask for help.... Ok then, See the install strings located in the sub dirs? well i want to be able to read in the branch of subs and look in each key.... i been playing with      {ReadSection(const Section: string; Strings: TStrings);} since that looks like what i need, but i get pretty error addresses when i do this... (object is to make an uninstaller this is the hard bit... i can assure you)

Thanks All for Your Help (Ps... waiting for other question to be deleted so i can up the points, so at the moment, i only have 40 to spare)
LVL 2
craig_capelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
Hi Craig,
are you after something like this:

procedure craig;
var
  reg  : TRegIniFile;
begin
  reg := TRegIniFile.Create( '' );
  reg.RootKey := HKEY_LOCAL_MACHINE;
  reg.createkey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\');
  reg.openkey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\',true);
 reg.readsection('Delphi4\',Form1.ListBox1.Items);
 {
or use this below and have the "=" as a delimiter between key
 and value and read into var and split to 2 seperate items..
 reg.ReadSectionValues('Delphi4\',Form1.Listbox2.Items);
 }
reg.CloseKey;
  reg.Free;
end;

could also use  getkeynames,getvaluenames etc ...

Regards Barry
0
craig_capelAuthor Commented:
before i even test this code (cos i know it will work) DO YOU EVER SLEEP??????
0
craig_capelAuthor Commented:
if you bare with us.... hold on until i get my other points... i will increase them, and you can have them.....? or if you want 40, your choice.. :)


Craig C.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

intheCommented:
People keep mentioning this thing called sleep..whats that then?

...hehe well yes but not very well ;-(

please test the code as it may need more ,i was not sure exactly what output you needed.

cheers Barry.
0
craig_capelAuthor Commented:
ah... nope you got what i already got :).... whats this getkeynames? its not the data inside the folder i need... imagine findfirst findnext going down the folders (while the data is inside (what you showed me)) so i can pull out each folder name and in turn extract the uninstall string.. if you have looked to see what i am doing?
0
intheCommented:
more ..more ..me want more..
hehe,shout if you need any more help for the code :-)
0
AttarSoftwareCommented:
Greedy boy!  ;O)

Nighty night all :)

Tim.
0
intheCommented:
yep i dont have winamp but the uninstall string seems similar to all folders.

ok back in a minute (maybe 15mins testing to be done ;-)
0
craig_capelAuthor Commented:
thanks Barry, my life does not exist without you..... and i mean that!...

Thanks 3 billion times over
0
craig_capelAuthor Commented:
oh and as for winamp... forget that it was the first folder on my list to look at.... :) you may even be supprised as what you find....
0
intheCommented:
ok what i did was place 2 listboxes on a for and a button(of course)

because i wanted to test it on folder with subfolder i enum-ed all the keys in the uninstall folder(you should be just able to change folder to winamp and should still work)
basically i added the jey names to listbox1 and the uninstall string to listbox2 (if dont have uinstall string i added 'Error'..
oh and as a note some keys have a value called "QuietUninstallString" instead .

if its not right just say and i try again ,eventually i get it right :-)

(i wasnt sure if want all the uninstall strings or just winamps)
0
intheCommented:
hehe suppose the code might help :

procedure craig;
var
  reg  : TRegIniFile;
  subkey : TStringlist;
  i : integer;
begin
  reg := TRegIniFile.Create( '' );
  reg.RootKey := HKEY_LOCAL_MACHINE;
  reg.createkey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\');
 if reg.openkey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\',false)
 then begin
        if (Reg.HasSubKeys) then begin
            SubKey := TStringlist.Create;
            Reg.GetKeyNames(SubKey);
            Form1.listbox1.items:=SubKey;
    for i := 0 to form1.listbox1.items.Count -1  do begin
Form1.listbox2.Items.Add(Reg.ReadString( Form1.listbox1.Items[i],'UninstallString','Error..'));
    end;
            SubKey.Free;
      end;
  Reg.CloseKey;
   end;
  reg.Free;
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intheCommented:
ps.
what components did you prefer to read these settings into?

0
mscatenaCommented:
You must create the TStringList object, like:

procedure craig;
var
  ...
  t: TStringList;  // You cannot create a TStrings because it's an abstract class
begin
  t := tstrings.Create;
  try
  ...
  finally
    t.Free;
  end;

end;


0
craig_capelAuthor Commented:
Adjusted points to 100
0
craig_capelAuthor Commented:
had to to increase the points :)  

Anyhow... what can  i say it worked a treat, exactly what i needed... thanks and thanks again...

Craig C....
0
craig_capelAuthor Commented:
maybee i should have done this first then made the comment :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.