How to check with Inno Setup, if a process is running at a Windows 2008 R2 64bit?

前端 未结 5 981
说谎
说谎 2020-12-09 05:08

I\'ve read the following post. My Code looks exactly the same, but does not work:
Inno Setup Checking for running process

I copied the example from http://www.vi

5条回答
  •  情书的邮戳
    2020-12-09 05:26

    I don't have enough rep points to add a comment to RRUZ's excellent answer, so I'll just add this here. Make sure you catch exceptions, otherwise the installer will fail for users who can't access the service.

    try
          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);
    except
    end;
    

提交回复
热议问题