RegReplaceKey or RegCreateKey API


how can i use these API function

RegReplaceKey or RegCreateKey

i want to create key and values under HKEY_LOCAL_COMPUTER
karen021897Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
philipleighsConnect With a Mentor Commented:
Hi Karen,

This is the sort of construct I use to access the registry. I hope this helps.

In specific response to your question, you have to set the RootKey property to HKEY_LOCAL_MACHINE.

Cheers,
Phil.


uses Windows, Registry;

....

function GetRegistryString(KeyName, ValueName: string): string;
var Reg: TRegistry;
begin
  Result := '';
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKeyReadOnly(KeyName) then
      begin
        Result := Reg.ReadString(ValueName);
        Reg.CloseKey;
      end;
  finally
    Reg.Free;
  end;
end;


0
 
karen021897Author Commented:
I cant create key under HKEY_LOCAL_COMPUTER with
TRegistry in Delphi, because i need access. I have heart i can
use these API functions

Can anybody help me?
0
 
philipleighsCommented:
Hi Karen,

TRegistry is just an OO wrapper for the API functions. If you're denied access through TRegistry, you'll get the same result through the APIs.

Cheers,
Phil.
 
0
 
karen021897Author Commented:
How can i then access the HKEY_LOCAL_COMPUTER?
0
 
karen021897Author Commented:
Great!!!
0
All Courses

From novice to tech pro — start learning today.