正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
卸载的时候,先判断这两个程序有没在运行,如果有运行就自动杀掉再卸载。
- function InitializeUninstall(): Boolean;
- var
- IsAppRunning: boolean;
- ResultCode: Integer;
- begin
- Result:= true;
- IsAppRunning:= IsModuleLoaded('AlarmRelay.exe');
- while IsAppRunning do
- begin
- if MsgBox('检测到AlarmRelay正在运行,卸载时请关闭!'#13'要自动关闭它并继续吗?', mbConfirmation, MB_OKCANCEL) = IDOK then
- begin
- Exec(ExpandConstant('{app}\janhkill.exe'), 'AlarmRelay.exe', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
- IsAppRunning:= IsModuleLoaded('AlarmRelay.exe');
- end
- else
- begin
- IsAppRunning:= false;
- Result:= false;
- end;
- end;
- if Result = true then
- begin
- IsAppRunning:= IsModuleLoaded('syncTime.exe');
- while IsAppRunning do
- begin
- if MsgBox('检测到syncTime正在运行,卸载时请关闭!'#13'要自动关闭它并继续吗?', mbConfirmation, MB_OKCANCEL) = IDOK then
- begin
- Exec(ExpandConstant('{app}\janhkill.exe'), 'syncTime.exe', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
- IsAppRunning:= IsModuleLoaded('syncTime.exe');
- end
- else
- begin
- IsAppRunning:= false;
- Result:= false;
- end;
- end;
- end;
- // UnloadDLL(ExpandConstant('{app}\psvince.dll'));
- end;
复制代码
用插件 psvince.dll 是可以识别的。注意:如果你是用的 Unicode 版,要用 AnsiString 类型,即:
function IsModuleLoaded(modulename: AnsiString): Boolean;
external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly';
而那个进程 syncTime.exe 并不是表示 syncTime.exe 这文件在运行,所以你也就不能用 janhkill.exe 杀掉它。其实它是一个由 syncTime.exe 安装的系统服务,你只要停止这个服务就行了,也就是说你不要用
Exec(ExpandConstant('{app}\janhkill.exe'), 'syncTime.exe', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
而要用
Exec('net.exe', 'stop syncTimeSrv', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
- function InitializeUninstall(): Boolean;
- var
- IsAppRunning: boolean;
- ResultCode: Integer;
- begin
- Result:= true;
- IsAppRunning:= IsModuleLoaded('AlarmRelay.exe');
- while IsAppRunning do
- begin
- if MsgBox('检测到AlarmRelay正在运行,卸载时请关闭!'#13'要自动关闭它并继续吗?', mbConfirmation, MB_OKCANCEL) = IDOK then
- begin
- Exec(ExpandConstant('{app}\janhkill.exe'), 'AlarmRelay.exe', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
- IsAppRunning:= IsModuleLoaded('AlarmRelay.exe');
- end
- else
- begin
- IsAppRunning:= false;
- Result:= false;
- end;
- end;
- if Result = true then
- begin
- IsAppRunning:= IsModuleLoaded('syncTime.exe');
- while IsAppRunning do
- begin
- if MsgBox('检测到syncTime正在运行,卸载时请关闭!'#13'要自动关闭它并继续吗?', mbConfirmation, MB_OKCANCEL) = IDOK then
- begin
- Exec('net.exe', 'stop syncTimeSrv', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
- //Exec(ExpandConstant('{app}\janhkill.exe'), 'syncTime.exe', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
- IsAppRunning:= IsModuleLoaded('syncTime.exe');
- end
- else
- begin
- IsAppRunning:= false;
- Result:= false;
- end;
- end;
复制代码 |