天天看點

安裝前判斷程序中是否有程式在運作

1.安裝前判斷程序中是否有程式在運作。

[files]

; 安裝前判斷程序,dll檔案放在inno的安裝目錄中

Source: compiler:psvince.dll; Flags: dontcopy noencryption

[Code]

//安裝前判斷是否有程序正在運作

function IsModuleLoaded(modulename: String ): Boolean;

external '[email protected]: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;

繼續閱讀