O método ReadString do Registro não está funcionando no Windows 7 no Delphi 7
O exemplo de código a seguir costumava me retornar o ID do Windows antes, mas agora não funciona e retorna uma string vazia, não sei por quê.
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;
Alguém pode ajudar?