Inno Setup to determine if the process exists before installation and stop the process < go >

Source: Internet
Author: User



Packaging the time to meet the requirements: Fake users are fool-like operation, if the update installation program, the old program is still running this time if you go to the prompt to let the user bar old program manual return is not realistic.



So when it comes to this situation can not be in the update installer, the update is the default when the old program to kill (if the old program is running).



The answer is clear that Inno Setup is capable of such operations.



Here is the article to go, thank the author for sharing.



==============================================================



Recently with Inno Setup want to do an EXE, but before the installation to stop the corresponding process is running, but found that its own method can not meet the requirements, finally found the corresponding information on the Internet, summarized here, convenient for later use.



1: If I just want to determine before the installation of a process exists, to introduce Psvince.dll this DLL, placed in the Inno Setup directory (the same directory as other DLLs), the code is as follows:


[files]

  ; Determine the process before installation, the dll file is placed in the inno installation directory
  Source: compiler: psvince.dll; Flags: dontcopy noencryption

// Determine if any processes are running before installation
function IsModuleLoaded (modulename: String): Boolean;
external ‘[email protected]: psvince.dll stdcall setuponly’;

function InitializeSetup (): Boolean;
var
     value: string;
     IsAppRunning: boolean;

begin
     // check Diagnosis press
     value: = ExpandConstant (‘(cm: DiagnosisRunning)‘);
     Result: = true;
     IsAppRunning: = IsModuleLoaded (‘Process name: such as mysql.exe’);
     while IsAppRunning do
     begin
         if MsgBox (‘** Tool is running, please close it first!’, mbConfirmation, MB_OKCANCEL) = IDOK then
         IsAppRunning: = IsModuleLoaded (‘Process name: such as mysql.exe’)
         else
         begin
             IsAppRunning: = false;
             Result: = false;
         end;
     end;
end; 


2: If I want to end a process before the installation, I will introduce IsTask.dll, placed in the installation directory of Inno Setup (same directory as other DLLs), the code is as follows:


[Files]
Source: D: \ FDisk \ makeexe \ fd \ *; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Do n‘t use "Flags: ignoreversion" on any shared system files
; Determine the process before installation, the dll file is placed in the inno installation directory
Source: compiler: IsTask.dll; Flags: dontcopy noencryption

[Code]
// Determine if a process is running before installation, the istask.dll file and the packaged exe file
function RunTask (FileName: string; bFullpath: Boolean): Boolean;
external ‘[email protected]: ISTask.dll stdcall delayload’;
function KillTask (ExeFileName: string): Integer;
external ‘[email protected]: ISTask.dll stdcall delayload’;

function InitializeSetup (): Boolean;
begin
  Result: = true;
  if RunTask (‘Process name: such as mysql.exe’, false) then
      begin
           if MsgBox ('The installer detected that ** is running!' # 13 '' # 13'Clicking the "Yes" button will stop the process and then continue the installation; '# 13' '# 13'Clicking the "No" button will terminate the installer ! ', mbConfirmation, MB_YESNO) = IDYES then
              begin
              KillTask (‘Process name: such as mysql.exe’);
              KillTask (‘mysqld.exe’);
              Result: = true;
              end
           else
              Result: = false;
      end
  else
  Result: = true;
end; 


Original address: 11073065



Inno Setup to determine if the process exists before installation and stop the process < go >


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.