Board index » delphi » D3: Registry: unable to open HKEY_LOCAL_MACHINE under NT4?!?!

D3: Registry: unable to open HKEY_LOCAL_MACHINE under NT4?!?!

Hi!

I have made a little application that accesses the Registry.  Here is a small
part of the code I use:

Procedure DoIt;
Var Registry : TRegistry;
    FileName : String;
    HeaderFile : String;
Begin
     Registry := TRegistry.Create;
     Try
        Registry.RootKey := HKEY_LOCAL_MACHINE;
        Registry.OpenKey(REGISTRY_ROOT, False);
        FileName := Registry.ReadString(REGISTRY_ROOTDIR) +
                    Registry.ReadString(REGISTRY_WEBDIR) + GetEnv('PATH_INFO');
[...]

(REGISTRY_ROOT is a constant defined earlier)

This piece of code works perfectly under Windows 95.  Under NT4 Workstation,
however, it doesn't work.  I used RegEdit to make sure REGISTRY_ROOT exists
under HKEY_LOCAL_MACHINE.  I also tried using True for CanCreate (for the
OpenKey), but it doesn't seem to be created anywhere...

I'm stumped here!  Is there something else I need to do before NT let me access
this part of the registry?  I was using the Administrator account...

Delphi 3.0 Pro
NT 4.0 Workstation SP3

-- Sylvain Demers   blackphoe...@cablevision.qc.ca

 

Re:D3: Registry: unable to open HKEY_LOCAL_MACHINE under NT4?!?!


Quote
>   blackphoe...@cablevision.qc.ca (Sylvain Demers) writes:
>  This piece of code works perfectly under Windows 95.  Under NT4 Workstation,
>  however, it doesn't work.  I used RegEdit to make sure REGISTRY_ROOT exists
>  under HKEY_LOCAL_MACHINE.  I also tried using True for CanCreate (for the
>  OpenKey), but it doesn't seem to be created anywhere...

>  I'm stumped here!  Is there something else I need to do before NT let me access
>  this part of the registry?  I was using the Administrator account...

I can only confirm that I have had the same problem. I added a thing to my programs so they would register the location on each machine. I am then using that for
automatic updates of new versions.
But on a NT machine I had to remove this to make it run:
  //  reg := tregistry.create; //?ppna registret    (Krashade p? NT)
  //  try
  //    reg.RootKey := HKEY_LOCAL_MACHINE;//G? till nyckeln local machine
  //    reg.OpenKey('\SOFTWARE\TT\TTDEWED.exe', True);//?ppna undernyckeln TT och TTDEWED.EXE
  //    reg.WriteString('path',extractfilepath(application.exename));//Skriv in s?kv?gen till programmet
  //  finally
  //    reg.free; //Frig?r registret
  //  end;

johan

Other Threads