INNO setup安装卸载钱判断进程中是否在运行总结
1.安装前判断进程中是否有程序在运行。
[files]
; 安装前判断进程,dll文件放在inno的安装目录中
Source: compiler:psvince.dll; Flags: dontcopy noencryption
[Code]
//安装前判断是否有进程正在运行
function IsModuleLoaded(modulename: String ): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall setuponly';
function InitializeSetup(): boolean;
var
IsAppRunning: boolean;
begin
Result:= true;
IsAppRunning:= IsModuleLoaded('WordTutor.exe');
while IsAppRunning do
begin
if MsgBox('快乐背单词正在运行,请先关闭它!', mbConfirmation, MB_OKCANCEL) = IDOK then
IsAppRunning:= IsModuleLoaded('WordTutor.exe')
else
begin
IsAppRunning:= false;
Result:= false;
end;
end;
end;
2.卸载前判断进程中是否在运行。
// 卸载前判断进程是否在运行.与安装相同的dll文件和需要打包的安装文件放在一起,也就是和.exe文件一起
[code]
function IsModuleLoadedU(modulename: String ): Boolean;
external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly';
function InitializeUninstall(): boolean;
var
IsAppRunning: boolean;
begin
Result:= true;
IsAppRunning:= IsModuleLoadedU('WordTutor.exe');
while IsAppRunning do
begin
if MsgBox('快乐背单词正在运行,请先关闭它!', mbConfirmation, MB_OKCANCEL) = IDOK then
IsAppRunning:= IsModuleLoadedU('WordTutor.exe')
else
begin
IsAppRunning:= false;
Result:= false;
end;
end;
end;