zoukankan      html  css  js  c++  java
  • Inno Setup 卸载前关闭进程或服务 x86 x64

    1、32位程序的PSVince.dll插件方法。

    [Setup]
    AppName=PSVince
    AppVerName=PSVince 1.0
    DisableProgramGroupPage=true
    DisableStartupPrompt=true
    OutputDir=.
    OutputBaseFilename=testpsvince
    Uninstallable=false
    DisableDirPage=true
    DefaultDirName={pf}PSVince
     
    [Files]
    Source: psvince.dll; Flags: dontcopy
     
    [Code]
    function IsModuleLoaded(modulename: AnsiString ):  Boolean;
    external 'IsModuleLoaded@files:psvince.dll stdcall';
     
    function InitializeSetup(): Boolean;
    begin
      if(IsModuleLoaded( 'notepad.exe' )) then
        begin
          MsgBox('Running', mbInformation, MB_OK);
          Result := false;
        end
      else
        begin
          MsgBox('Not running', mbInformation, MB_OK);
          Result := true;
        end
    end;
     
    2、 PSVince控件在64位系统(Windows 7/Server 2008/Server 2012)下无法检测到进程,使用下面的函数可以解决。
    function IsAppRunning(const FileName : string): Boolean;
    var
        FSWbemLocator: Variant;
        FWMIService   : Variant;
        FWbemObjectSet: Variant;
    begin
        Result := false;
        FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
        FWMIService := FSWbemLocator.ConnectServer('', 'rootCIMV2', '', '');
        FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
        Result := (FWbemObjectSet.Count > 0);
        FWbemObjectSet := Unassigned;
        FWMIService := Unassigned;
        FSWbemLocator := Unassigned;
    end;
  • 相关阅读:
    flask读书笔记-flask web开发
    flask 杂记
    ubuntu redis 安装 &基本命令
    redis 订阅&发布(转载)
    Redis键值设计(转载)
    python2 python3区别
    捕获异常
    开源的微信个人号接口
    工具
    HDU2966 In case of failure(浅谈k-d tree)
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/4135734.html
Copyright © 2011-2022 走看看