Writing to registry - HKEY_CURRENT_USER and various Windows accounts?

From: Lauchlan M (LMackinnon_at_NOSPAMHotmail.com)
Date: 01/22/04

  • Next message: Tom Head: "Re: Single Thread problem"
    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


  • Next message: Tom Head: "Re: Single Thread problem"

    Relevant Pages

    • Re: VFP Updates?
      ... Account", which is what many users do, e.g. in company networks. ... WinXP limited accounts as well as Vista UAC is quite easy ... considerations for installing and running a VFP app in Vista. ... directory/folder IS), and you don't need to write to registry, I think ...
      (microsoft.public.fox.programmer.exchange)
    • Re: Cant set OE as default client in User Account
      ... spyware and MSSYCLM being in other parts of the registry. ... neither OE nor IE show as defaults in the User account. ... Everything is fine in the Administrator account. ... "Outlook Express is not currently your default mail client. ...
      (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
    • Re: registry hacked under XP limited account
      ... >> The thing I want to know is that the registry can be modified ... Running as limited account does VERY LITTLE to stop ... running with administrative rights is a VERY BAD HABIT. ... This tactic will NOT be effective against future malware. ...
      (microsoft.public.security)
    • Re: Cant set OE as default client in User Account
      ... "Jim Pickering" wrote: ... In looking at the registry, I've found changes being made in a couple ... the particular account that's having the problem. ... Everything is fine in the Administrator account. ...
      (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
    • RE: Moving user account from NT to Win2k3
      ... I found that there is no "Shared icon" under folder in the tree ... After importing the registry successfully, you may want to restart the ... When creating a new user account, the SID of the account has been ... Microsoft Online Partner Support ...
      (microsoft.public.windows.server.migration)

    Loading