Writing to registry - HKEY_CURRENT_USER and various Windows accounts?
From: Lauchlan M (LMackinnon_at_NOSPAMHotmail.com)
Date: 01/22/04
- Previous message: Joe Gabriele: "Re: Check whether a running application has a visible window"
- Next in thread: JED: "Re: Writing to registry - HKEY_CURRENT_USER and various Windows accounts?"
- Reply: JED: "Re: Writing to registry - HKEY_CURRENT_USER and various Windows accounts?"
- Reply: Rob Kennedy: "Re: Writing to registry - HKEY_CURRENT_USER and various Windows accounts?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Jan 2004 10:38:49 +1000
Say I install an app in administrator account and it can be used from a
number of accounts
Then I have some code that uses the registry, say
procedure TForm1.btnWriteRegistryClick(Sender: TObject);
var
Reg: TRegistry;
begin
Reg :=TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('\Software\mySoftwareName\Config', true) then
begin
Reg.WriteString('LocationID','TEST');
Reg.CloseKey;
end;
finally
Reg.Free;
inherited;
end;
end;
procedure TForm1.btnReadRegistryClick(Sender: TObject);
var
Reg: TRegistry;
begin
Reg :=TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('\Software\mySoftwareName\Config',False) then //False
because we do not want to create it if it doesn't exist
MessageDlg(Reg.ReadString('LocationID'), mtInformation, [mbOk], 0)
else
MessageDlg('Couldn''t find registry key.', mtInformation, [mbOk], 0);
Reg.CloseKey;
finally
Reg.Free;
inherited;
end;
end;
Firstly, what does this 'inherited' do? (This was in the registry examples
in the online help so I copied that over, but aren't sure what purpose it
serves)
Secondly, is hanging everything off HKEY_CURRENT_USER the best place?
Suppose the app was installed under an administrator account but then used
by several users in different accounts - would they have different
HKEY_CURRENT_USER keys? Is there a better place to put it so I can be sure
that I retreive the registry key properly regardless of which Windows
account is being used?
Thanks!
Lauchlan M
- Previous message: Joe Gabriele: "Re: Check whether a running application has a visible window"
- Next in thread: JED: "Re: Writing to registry - HKEY_CURRENT_USER and various Windows accounts?"
- Reply: JED: "Re: Writing to registry - HKEY_CURRENT_USER and various Windows accounts?"
- Reply: Rob Kennedy: "Re: Writing to registry - HKEY_CURRENT_USER and various Windows accounts?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|