当前位置:网站首页>Innosetup method for judging that the program has run

Innosetup method for judging that the program has run

2022-06-22 05:33:00 Kingston

You can use the WMI and the Win32_Process.

Try adding this function to your Inno Setup script.

function IsAppRunning(const FileName : string): Boolean;
var
    FSWbemLocator: Variant;
    FWMIService   : Variant;
    FWbemObjectSet: Variant;
begin
    Result := false;
    FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
    FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
    FWbemObjectSet :=
      FWMIService.ExecQuery(
        Format('SELECT Name FROM Win32_Process Where Name="%s"', [FileName]));
    Result := (FWbemObjectSet.Count > 0);
    FWbemObjectSet := Unassigned;
    FWMIService := Unassigned;
    FSWbemLocator := Unassigned;
end;
原网站

版权声明
本文为[Kingston]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220525509021.html