Ele*_*ios 3 windows installer inno-setup pascalscript
我想知道如何确定目标机器中是否安装了特定的Windows Update软件包,例如名称为KB2919355的Windows Update软件包.
是否存在内置功能来检查?如果没有,那么确定它所需的代码是什么?也许搞乱注册表,或者可能是最干净和/或最安全的方式?
伪代码:
[Setup]
...
[Files]
Source: {app}\*; DestDir: {app}; Check: IsPackageInstalled('KB2919355')
[Code]
function IsPackageInstalled(packageName): Boolean;
begin
...
Result := ...;
end;
Run Code Online (Sandbox Code Playgroud)
function IsKBInstalled(KB: string): Boolean;
var
WbemLocator: Variant;
WbemServices: Variant;
WQLQuery: string;
WbemObjectSet: Variant;
begin
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('', 'root\CIMV2');
WQLQuery := 'select * from Win32_QuickFixEngineering where HotFixID = ''' + KB + '''';
WbemObjectSet := WbemServices.ExecQuery(WQLQuery);
Result := (not VarIsNull(WbemObjectSet)) and (WbemObjectSet.Count > 0);
end;
Run Code Online (Sandbox Code Playgroud)
使用如下:
if IsKBInstalled('KB2919355') then
begin
Log('KB2919355 is installed');
end
else
begin
Log('KB2919355 is not installed');
end;
Run Code Online (Sandbox Code Playgroud)
积分: