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?
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.

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
philipleighsCommented:
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

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
karen021897Author Commented:
Great!!!
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.