I use the following two routines to read and write strings to the registry.  
They work fine under all 32 bit conditions, but seem to produce very 
inconsistent results under 64 bit windows (2003).

procedure WriteRegValue(const RootKey: HKEY;const Key, Name, Value: string);
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create(KEY_ALL_ACCESS);
  try {finally}
    Reg.RootKey := RootKey;

    if not Reg.KeyExists(Key) then
      if not Reg.CreateKey(Key) then
        Exit;

    if Reg.OpenKey(Key, True) then
      Reg.WriteString(Name, Value);

  finally
    Reg.Free;
  end; {finally}
end;

function ReadRegValue(const RootKey: HKEY;const Key, Name, DefaultValue: 
string): string;
var
  Reg: TRegistry;
begin
  Result := DefaultValue;

  Reg := TRegistry.Create(KEY_READ);
  try {finally}
    Reg.RootKey := RootKey;

    if Reg.KeyExists(Key) then
      if Reg.OpenKeyReadOnly(Key) then
        if Reg.ValueExists(Name) then
          case Reg.GetDataType(Name) of
            rdUnknown     : ;
            rdString      : Result := Reg.ReadString(Name);
            rdExpandString: Result := Reg.ReadString(Name);
            rdInteger     : Result := IntToStr(Reg.ReadInteger(Name));
            rdBinary      : ;
          end; {case}

  finally
    Reg.Free;
  end; {finally}
end;


I have 2 applications that use these same routines:

The first works fine for all users, the values are written and read fine, 
although the values are stored in the 64 bit section (ie not under 
wow6432node)...

The second application works fine for one user (as above in the 64bit section), 
but for other users on the same machine (terminal server), the values are 
written but not read.  Even if the values are replicated under the wow6432node, 
they are not read back.

I know this is not a permissions issue, but just cannot figure out what is 
required to read and write reliably from the registry under 64 bit windows...?

any help would be greatly appreciated (!)

tia
Paul

_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to