Make(delphi) ver(4.04 build 185) Add(MainForm,3385792,182,154) { Width=542 Height=233 Caption="OS Info" BorderStyle=3 Position=1 } Add(InlineCode,5765439,259,147) { VarPoints=#14:GetProductName|12:GetProductID|14:GetSerialOSKey|13:GetSystemType|13:GetServicePak| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|29:uses kol,windows,Share,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|54: procedure GetProductName(var dt:TData; idx:word);|52: procedure GetProductID(var dt:TData; idx:word);|54: procedure GetSerialOSKey(var dt:TData; idx:word);|53: procedure GetSystemType(var dt:TData; idx:word);|53: procedure GetServicePak(var dt:TData; idx:word);|5: end;|0:|14:implementation|0:|5:const|64: sKeyWin = 'SOFTWARE\MICROSOFT\Windows NT\CurrentVersion';|36: sValueName = 'DigitalProductId';|31: sProductName = 'ProductName';|29: sProductID = 'ProductID';|30: sServicePak = 'CSDVersion';|44: sKeyChars = 'BCDFGHJKMPQRTVWXY2346789';|0:|93: KEY_WOW64_64KEY = $0100; // Access a 64-bit key from either a 32-bit or 64-bit application.|93: KEY_WOW64_32KEY = $0200; // Access a 32-bit key from either a 32-bit or 64-bit application.|0:|26:function IsWin64: Boolean;|4:type|76: TIsWow64Process = function(Handle: THandle; var Res: BOOL): BOOL; stdcall;|3:var|22: IsWow64Result: BOOL;|34: IsWow64Process: TIsWow64Process;|5:begin|18: Result := False;|80: IsWow64Process := GetProcAddress(GetModuleHandle(Kernel32), 'IsWow64Process');|87: if Assigned(IsWow64Process) and IsWow64Process(GetCurrentProcess, IsWow64Result) then|28: Result := IsWow64Result;|6:end; |0:|65:function RegKeyOpenRead64(Key: HKey; const SubKey: String): HKey;|5:begin|99: if RegOpenKeyEx(Key, PChar(SubKey), 0, KEY_READ or KEY_WOW64_64KEY, Result) <> ERROR_SUCCESS then|16: Result := 0;|4:end;|0:|31:function Get_ServicePak:string;|3:var|23: strServicePak:string;|11: Key:HKey;|5:begin|15: Result := '';|5: try|17: if IsWin64 then|55: Key := RegKeyOpenRead64(HKEY_LOCAL_MACHINE,sKeyWin)|7: else |57: Key := RegKeyOpenRead(HKEY_LOCAL_MACHINE,sKeyWin); |37: if Key = ERROR_SUCCESS then Exit;|52: strServicePak := RegKeyGetStr(Key, sServicePak);|9: finally|21: RegKeyClose(Key);|6: end;|26: Result := strServicePak;|4:end;|0:|0:|30:function Get_ProductID:string;|3:var|22: strProductID:string;|11: Key:HKey;|5:begin|15: Result := '';|5: try|17: if IsWin64 then|55: Key := RegKeyOpenRead64(HKEY_LOCAL_MACHINE,sKeyWin)|7: else |57: Key := RegKeyOpenRead(HKEY_LOCAL_MACHINE,sKeyWin); |37: if Key = ERROR_SUCCESS then Exit;|50: strProductID := RegKeyGetStr(Key, sProductID);|9: finally|21: RegKeyClose(Key);|6: end;|25: Result := strProductID;|4:end;|0:|32:function Get_ProductName:string;|3:var|24: strProductName:string;|11: Key:HKey;|5:begin|15: Result := '';|5: try|17: if IsWin64 then|55: Key := RegKeyOpenRead64(HKEY_LOCAL_MACHINE,sKeyWin)|7: else |57: Key := RegKeyOpenRead(HKEY_LOCAL_MACHINE,sKeyWin); |37: if Key = ERROR_SUCCESS then Exit;|54: strProductName := RegKeyGetStr(Key, sProductName);|9: finally|21: RegKeyClose(Key);|6: end;|27: Result := strProductName;|4:end;|0:|32:function Get_SerialOSKey:string;|3:var|35: bDigitalProductID: array of byte;|29: bProductKey: array of byte;|25: blByte, blKeyByte:byte;|32: nCur, intLenKey, i, j:integer;|14: sKey:string;|11: Key:HKey;|5:begin|44: Result := 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX';|5: try|17: if IsWin64 then|55: Key := RegKeyOpenRead64(HKEY_LOCAL_MACHINE,sKeyWin)|7: else |57: Key := RegKeyOpenRead(HKEY_LOCAL_MACHINE,sKeyWin); |37: if Key = ERROR_SUCCESS then Exit;|50: intLenKey := RegKeyValueSize(Key, sValueName);|44: SetLength(bDigitalProductID, intLenKey);|38: SetLength(bProductKey, intLenKey);|83: intLenKey := RegKeyGetBinary(Key, sValueName, bDigitalProductID[0], intLenKey);|9: finally|21: RegKeyClose(Key);|6: end;|0:|27: for blByte := 52 to 66 do|58: bProductKey[blByte - 52] := bDigitalProductID[blByte];|0:|34: blByte := 24; blKeyByte := 14;|21: for i:= 0 to 24 do|8: begin|15: nCur := 0;|24: for j := 0 to 14 do|10: begin|55: nCur := (nCur * 256) xor bProductKey[blKeyByte];|55: bProductKey[blKeyByte] := Round(Int(nCur / 24));|29: nCur := (nCur mod 24);|22: dec(blKeyByte);|9: end;|0:|38: sKey := sKeyChars[nCur+1] + sKey;|51: if ((blByte mod 5) = 0) and (blByte <> 0) then|26: sKey := '-' + sKey;|17: dec(blByte);|21: blKeyByte := 14;|7: end;|17: Result := sKey;|4:end;|0:|37:procedure THiAsmClass.GetProductName;|3:var|16: strRes:string;|5:begin|28: strRes := Get_ProductName;|22: dtString(dt,strRes);|4:end;|0:|35:procedure THiAsmClass.GetProductID;|3:var|16: strRes:string;|5:begin|26: strRes := Get_ProductID;|22: dtString(dt,strRes);|4:end;|0:|37:procedure THiAsmClass.GetSerialOSKey;|3:var|16: strRes:string;|5:begin|28: strRes := Get_SerialOSKey;|22: dtString(dt,strRes);|4:end;|0:|36:procedure THiAsmClass.GetServicePak;|3:var|16: strRes:string;|5:begin|27: strRes := Get_ServicePak;|22: dtString(dt,strRes);|4:end;|0:|36:procedure THiAsmClass.GetSystemType;|5:begin|65: if IsWin64 then dtString(dt,'(x64)') else dtString(dt,'(x32)');|4:end;|0:|4:end.| } Add(Button,11755785,182,203) { Left=135 Top=15 Width=235 Height=45 Font=[MS Sans Serif,18,1,0,1] Caption="GetInfo" link(onClick,8898031:doString,[]) } Add(FormatStr,8898031,259,203) { DataCount=5 Mask="Product name: %1 %4\r\nService pak: %5\r\nProduct ID: %2\r\nSerial key: %3" link(onFString,11178283:doAdd,[]) link(Str1,5765439:GetProductName,[]) link(Str2,5765439:GetProductID,[]) link(Str3,5765439:GetSerialOSKey,[]) link(Str4,5765439:GetSystemType,[]) link(Str5,5765439:GetServicePak,[]) } Add(Memo,11178283,329,203) { Left=15 Top=85 Width=505 Height=110 Font=[Courier New,14,1,0,204] }