this slowpoke moves

Get Windows XP Product Key

uses Registry

//

function GetWinProductKey: string;  
const  
  Digits = 'BCDFGHJKMPQRTVWXY2346789';
var  
  Reg: TRegistry;
  Value: String;  
  i,j,x: Integer;  
begin  
  Result := '';  
  Reg := TRegistry.Create(KEY_READ);  
  try  
    Reg.RootKey := HKEY_LOCAL_MACHINE;  
    Reg.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion', False);  
    SetLength(Value, Reg.GetDataSize('DigitalProductID'));  
    if (Length(Value) >= 67) then  
    begin  
      Reg.ReadBinaryData ('DigitalProductID', Value[1], Length (Value));  
      for i := 24 downto 0 do  
      begin  
        x := 0;  
        for j := 14 downto 0 do  
        begin  
          x := (x shl 8) + Ord(Value[53+j]);  
          Value[53+j] := Char(x div 24);  
          x := x mod 24;  
        end;  
        Result := Digits[x+1] + Result;  
        if ( (i > 0) and ((i mod 5) = 0) ) then  
          Result := '-' + Result;  
      end;  
    end;  
  finally  
    Reg.Free;  
  end;  
end; 
Beispiel :
procedure TForm1.FormCreate(Sender: TObject);
begin
	Edit1.Text := GetWinProductKey; 
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate