我使用了ISTask.dll,但是好像只能检测32位进程,64位的没效果,请问老虎版主有没有好方法。
下面是测试代码:
[Setup]
AppName=abc
AppVersion=1.5
DefaultDirName={pf}\abc
OutputBaseFilename=abc
DefaultGroupName=abc
OutputDir=.
[Files]
Source: "ISTask.dll"; Flags: dontcopy solidbreak;
[Code]
function RunTask(FileName: string; bFullpath: Boolean): Boolean;
external 'RunTask@files:ISTask.dll stdcall delayload';
function KillTask(ExeFileName: string): Integer;
external 'KillTask@files:ISTask.dll stdcall delayload';
function InitializeSetup(): Boolean;
var
ErrorCode:integer;
begin
Result := True;
if iswin64 then //64位进程检测不到,会直接出现安装界面
begin
ShellExec ('', ExpandConstant('{src}\MyProg-x64.exe'), '', '', SW_SHOW, ewNoWait, ErrorCode);
if RunTask('MyProg-x64.exe', false) then
if MsgBox('检测到程序正在运行,要关闭吗?', mbConfirmation, MB_YESNO) = IDYES then
KillTask('MyProg-x64.exe')
else
Result := False;
end else
begin
ShellExec ('', ExpandConstant('{src}\MyProg.exe'), '', '', SW_SHOW, ewNoWait, ErrorCode);
if RunTask('MyProg.exe', false) then
if MsgBox('检测到程序正在运行,要关闭吗?', mbConfirmation, MB_YESNO) = IDYES then
KillTask('MyProg.exe')
else
Result := False;
end
end;
测试脚本.rar (36 K) 下载次数:0