Registry ReadString method is not working in Windows 7 in Delphi 7
        Posted  
        
            by Tofig Hasanov
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Tofig Hasanov
        
        
        
        Published on 2010-04-19T11:03:28Z
        Indexed on 
            2010/04/19
            11:13 UTC
        
        
        Read the original article
        Hit count: 697
        
The following code sample used to return me windows id before, but now it doesn't work, and returns empty string, dunno why.
  function GetWindowsID: string;
  var
    Registry: TRegistry;
    str:string;
  begin
    Registry := TRegistry.Create(KEY_WRITE);
    try
      Registry.Lazywrite := false;
      Registry.RootKey := HKEY_LOCAL_MACHINE;
   //   Registry.RootKey := HKEY_CURRENT_USER;
      if CheckForWinNT = true then
       Begin
       if not Registry.OpenKeyReadOnly('\Software\Microsoft\Windows NT\CurrentVersion') then showmessagE('cant open');
       end
      else
        Registry.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion');
      str := Registry.ReadString('ProductId');
      result:=str;
      Registry.CloseKey;
    finally
      Registry.Free;
    end; // try..finally
  end;
Anybody can help?
© Stack Overflow or respective owner