Inno setup installer在向导中显示BIOS串行的盐渍散列值



如何在inno setup wizard中显示BIOS serial的盐渍散列值

wmic bios get serialnumber这个命令将给bios序列号。但是不知道如何在inno设置中使用。

我要用它来生成密码所以在同一个向导中也应该有一个密码字段

感谢

@LexLi是正确的,已经有关于读取wmic输出到Inno Setup的问题,例如:解析Inno Setup中的wmic输出

但我的回答也说,这并不容易,因为wmic输出UTF-16,最好使用WMI API。参考Is there a way to read the system's information in Inno Setup

function InitializeSetup(): Boolean;
var
WbemLocator, WbemServices, Bios: Variant;
Query: string;
begin
Result := True;
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('.', 'rootCIMV2');
Query := 'SELECT SerialNumber FROM Win32_BIOS';
Bios := WbemQuery(WbemServices, Query);
if not VarIsNull(Bios) then
begin
Code := GetSHA1OfString(Trim(Bios.SerialNumber) + 'Salt');
Log(Format('Code is [%s]', [Code]));
end
else
begin
MsgBox('Cannot get computer code', mbError, MB_OK);
Result := False;
end;
end;

以上代码将散列后的序列号存储到Code变量中。你可以在任何你喜欢的地方使用它。