Yaliang Posted July 21, 2014 Posted July 21, 2014 (edited) There are some ways to do this. Such as using a external DLL.But I do not like this way.The Inno surport Pascal script. The Pascal script can call standard Win32 API functions inside standard Windows DLLs. So we can check the app is whether running.Here is a part of script in section:; Any question, let me know.;It work on 32 and 64 modules![code]type HANDLE = LongInt;HMODULE = HANDLE;pHMODULE = Array[0..255] of HMODULE;LPDWORD = DWORD; PDWORD = Array[0..255] of DWORD;LPTSTR = String;const PROCESS_QUERY_INFORMATION = $400;PROCESS_VM_READ = $10;MAX_LENGTH = 255;function OpenProcess(dwDesiredAccess : DWORD; bInheritHandle : Boolean; dwProcessId : DWORD) : HANDLE;external 'OpenProcess@kernel32.dll stdcall delayload';function CloseHandle(hObject : HANDLE) : BOOL;external 'CloseHandle@kernel32.dll stdcall delayload';function EnumProcesses(var pProcessIds : PDWORD; cb : DWORD; var pBytesReturned : DWORD) : BOOL;external 'EnumProcesses@psapi.dll stdcall delayload';//notice:delayload EnumProcessModules and EnumProcessModulesEx functions//64-bit using EnumProcessModulesEx; 32-bite using EnumProcessModules function EnumProcessModulesEx(hProcess : HANDLE; var lphModule : pHMODULE; cb : DWORD; var lpcbNeeded : LPDWORD; dwFilterFlag : DWORD) : BOOL;external 'EnumProcessModulesEx@psapi.dll stdcall delayload';function EnumProcessModules(hProcess : HANDLE; var lphModule : pHMODULE; cb : DWORD; var lpcbNeeded : LPDWORD) : BOOL;external 'EnumProcessModules@psapi.dll stdcall delayload';function GetModuleFileNameExW(hProcess : HANDLE; hModule : HMODULE; lpFilename : LPTSTR; nSize : DWORD) : DWORD;external 'GetModuleFileNameExW@psapi.dll stdcall delayload';//here is the functionfunctionzylIsAppRunning(procName : String; fullPath : Boolean) : Boolean;var found : Boolean;filenameEnd : Integer;filename : String;NA : DWORD;entry : DWORD;maxEntries : DWORD;processes : PDWORD;lpFilename : LPTSTR;hProcess : HANDLE;hMod : pHMODULE;isModuleShot: Boolean;beginSetLength(lpFilename, MAX_LENGTH);found := False;if (EnumProcesses(processes, SizeOf(processes), maxEntries)) thenbeginentry := 0;maxEntries := maxEntries / SizeOf(maxEntries);while ((not found) and (entry < maxEntries)) do beginhProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, processes[entry]);if (hProcess <> 0) thenbeginisModuleShot := False;if IsWin64 thenbegin //EnumProcessModulesEx @param $3,surport 32-bit modules and 64-bit modules the sametiemisModuleShot := EnumProcessModulesEx(hProcess, hMod, SizeOf(hMod), NA, $3);end else beginisModuleShot := EnumProcessModules(hProcess, hMod, SizeOf(hMod), NA);end;if (isModuleShot) thenif (GetModuleFileNameExW(hProcess, hMod[0], lpFilename, Length(lpFilename)) > 0)then beginfilenameEnd := Pos(#0, lpFilename);filename := Copy(Lowercase(lpFilename), 1, filenameEnd - 1);if (not fullpath) thenfilename := ExtractFileName(filename);if (AnsiLowercase(filename) = AnsiLowercase(procName)) thenfound := True;end;CloseHandle(hProcess);end;entry := entry + 1;end;end;Result := found;end;//function end How to use:I wish you have installed the Unicode Inno Setup (the 5.5.x version or more).(If not, you can download it from the home page http://www.jrsoftware.org)You can use it where you need just like:zylIsAppRunning('notdpad.exe', false);An example project for Unicode Inno Setup is provided as download.The attachment "CheckAppRunning.zip" is the script.Unzip the file CheckAppRunning.zip,you can get a file named "CheckAppRunning.iss".Please copy the *.iss files to the directory: ./Inno Setup 5/ExamplesThen build the program and run it.CheckAppRunning.zip Edited July 31, 2014 by Yaliang meoit, alfreire, niTe_RiDeR_Pr0 and 2 others 5 Quote
ricktendo Posted July 23, 2014 Posted July 23, 2014 Another very useful script, thank you so much will give it a try Quote
Yaliang Posted July 23, 2014 Author Posted July 23, 2014 Another very useful script, thank you so much will give it a try I had reuploaded the example as download. The script costed me lot of time. And I try many ways.but share with other is happy. alfreire 1 Quote
ricktendo Posted August 29, 2014 Posted August 29, 2014 Hope to use this on my daemon tools lite repack Quote
Yaliang Posted September 9, 2014 Author Posted September 9, 2014 Hope to use this on my daemon tools lite repack It is my pleasure.Any question u can post here and we can work it out. alfreire 1 Quote
niTe_RiDeR_Pr0 Posted November 21, 2014 Posted November 21, 2014 (edited) Hi, here is my script: ;InnoSetupVersion=5.5.0[Setup]AppName=Adobe Flash Player 15 + Shockwave Player 12 + Adobe Air 15 - AiOAppVersion=15.12.15AppPublisher=Adobe Systems, Inc.AppPublisherURL=www.adobe.comOutputBaseFilename=AdobeRuntimes_AiO_15.12.15_niTe.RiDeRCompression=lzma2/ultra64Uninstallable=noDisableProgramGroupPage=yesWizardImageFile=embedded\WizardImage.bmpLicenseFile=embedded\LicenseAgreement.rtfSolidCompression=yesInternalCompressLevel=ultraSetupIconFile=embedded\SetupIcon.icoWizardSmallImageFile=embedded\WizardSmallImage.bmpVersionInfoVersion=15.12.15VersionInfoCompany=Adobe Systems IncorporatedVersionInfoDescription=Adobe Runtimes AiO (Adobe Shockwave Player v12.1.4.154 + Flash Player v15.0.0.223 + Adobe AIR) RePacked SetupVersionInfoProductName=Adobe Runtimes AiOVersionInfoProductVersion=15.12.15VersionInfoProductTextVersion=12.12.15CreateAppDir=False[Files]Source: "{app}\install_flash_player_15_active_x.exe"; DestDir: "{tmp}"; Components: flashactivex; MinVersion: 0.0,5.01; Flags: deleteafterinstallSource: "{app}\install_flash_player_15_plugin.exe"; DestDir: "{tmp}"; Components: flashplugin; MinVersion: 0.0,5.01; Flags: deleteafterinstallSource: "{app}\sw_lic_full_installer.msi"; DestDir: "{tmp}"; Components: shockwave; MinVersion: 0.0,5.01; Flags: deleteafterinstallSource: "{app}\AdobeAIRInstaller.exe"; DestDir: "{tmp}"; Components: air; MinVersion: 0.0,5.01; Flags: deleteafterinstall Source: "embedded\ISWin7.dll"; DestDir: "{tmp}"; Flags: dontcopy nocompressionSource: "embedded\processviewer.exe"; DestDir: "{tmp}"; Flags: dontcopy[Run]Filename: "{tmp}\install_flash_player_15_active_x.exe"; Parameters: "-install"; StatusMsg: "Installing Flash Player 15 ActiveX; This can take a few minutes & the installer will freeze for a few seconds, so please wait..."; Components: flashactivex; MinVersion: 0.0,5.01;Filename: "{tmp}\install_flash_player_15_plugin.exe"; Parameters: "-install"; StatusMsg: "Installing Flash Player 15 Plugin; this can take few minutes & the installer will freeze for a few seconds, so please wait..."; Components: flashplugin; MinVersion: 0.0,5.01;Filename: "{tmp}\sw_lic_full_installer.exe"; Parameters: "/qb"; StatusMsg: "Installing Shockwave Player 12; This could take a few minutes & the installer will freeze for a few seconds, so please wait..."; Components: shockwave; MinVersion: 0.0,5.01;Filename: "{tmp}\AdobeAIRInstaller.exe"; Parameters: "-silent"; StatusMsg: "Installing Adobe AIR 15; this may take a few minutes & the installer will freeze for a few seconds, so please wait..."; Components: air; MinVersion: 0.0,5.01;[Components]Name: "flashplugin"; Description: "Adobe Flash Player v15.0.0.223 Plugin"; Types: "compact full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760Name: "flashactivex"; Description: "Adobe Flash Player v15.0.0.223 ActiveX"; Types: "compact full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760Name: "shockwave"; Description: "Adobe Shockwave Player v12.1.4.154"; Types: "compact full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760Name: "air"; Description: "Adobe AIR v15.0.0.356"; Types: "full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760[Messages]SelectComponentsLabel2=Select the runtimes you want to install; clear the runtimes you do not want to install. Click Next when you are ready to continue.WizardSelectComponents=Select RuntimesSelectComponentsDesc=Which runtimes should be installed?[Code]{ RedesignWizardFormBegin } // Don't remove this line!// Don't modify this section. It is generated automatically.var ISCustomPage2: TWizardPage; ISCustomPage3: TWizardPage; ISCustomPage1: TWizardPage; ISCustomPage4: TWizardPage; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel;procedure RedesignWizardForm;begin { Creates custom wizard page } ISCustomPage4 := CreateCustomPage(wpWelcome, 'Description', 'A Description of the Runtimes (Components)'); with WizardForm do begin AutoScroll := False; ClientHeight := ScaleY(363); ClientWidth := ScaleX(490); Caption := 'Setup - Adobe Runtimes AiO RePack'; end; with WizardForm.CancelButton do begin Left := ScaleX(404); end; with WizardForm.NextButton do begin Left := ScaleX(319); end; with WizardForm.BackButton do begin Left := ScaleX(244); end; with WizardForm.WizardBitmapImage do begin Width := ScaleX(180); end; with WizardForm.WelcomeLabel2 do begin Caption := 'This will install Adobe Flash Player 15 + Shockwave Player 12 + Adobe AIR 15 - AiO on your computer.' + #13#10 + '' + #13#10 + 'It is strongly recommended to close Google Chrome & Mozilla Firefox if they are open, otherwise the setup may require a reboot.' + #13#10 + 'You can choose which runtimes to install.' + #13#10 + '' + #13#10 + 'Click Next to continue, or Cancel to exit Setup.'; Left := ScaleX(184); Top := ScaleY(96); Width := ScaleX(293); Height := ScaleY(212); end; with WizardForm.WelcomeLabel1 do begin Caption := 'Welcome to the Adobe Runtimes AiO Setup Wizard by -=niTe_RiDeR_Pro=-'; Left := ScaleX(184); Width := ScaleX(307); Height := ScaleY(78); end; with WizardForm.ComponentsList do begin Top := ScaleY(69); end; { Label7 } Label7 := TLabel.Create(WizardForm); with Label7 do begin Name := 'Label7'; Parent := WizardForm; Caption := 'RePack by niTe_RiDeR_Pro'; Font.Color := clWindowText; Font.Height := -11; Font.Name := 'Tahoma'; Font.Style := [fsItalic]; ParentFont := False; Left := ScaleX(14); Top := ScaleY(331); Width := ScaleX(130); Height := ScaleY(13); end; { ISCustomPage4 } with ISCustomPage4.Surface do begin Color := clBtnFace; end; { Label1 } Label1 := TLabel.Create(WizardForm); with Label1 do begin Parent := ISCustomPage4.Surface; Caption := 'Adobe Flash Player:'; Font.Color := clWindowText; Font.Height := -11; Font.Name := 'Tahoma'; Font.Style := [fsBold]; ParentFont := False; Left := ScaleX(8); Top := ScaleY(8); Width := ScaleX(110); Height := ScaleY(13); end; { Label2 } Label2 := TLabel.Create(WizardForm); with Label2 do begin Parent := ISCustomPage4.Surface; AutoSize := False; Caption := 'Adobe Flash Player is the standard for delivering high-impact, rich Web content. ' + #13#10 + 'Designs, animation, and application user interfaces are deployed immediately across' + #13#10 + 'attracting and engaging users with a rich Web experience.'; Left := ScaleX(8); Top := ScaleY(24); Width := ScaleX(407); Height := ScaleY(61); end; { Label3 } Label3 := TLabel.Create(WizardForm); with Label3 do begin Parent := ISCustomPage4.Surface; Caption := 'Adobe Shockwave Player:'; Font.Color := clWindowText; Font.Height := -11; Font.Name := 'Tahoma'; Font.Style := [fsBold]; ParentFont := False; Left := ScaleX(8); Top := ScaleY(80); Width := ScaleX(145); Height := ScaleY(13); end; { Label4 } Label4 := TLabel.Create(WizardForm); with Label4 do begin Parent := ISCustomPage4.Surface; Caption := 'Shockwave Player is the web standard for powerful multimedia playback. The ' + #13#10 + 'Shockwave Player allows you to view interactive web content like games,' + #13#10 + ' business presentations, entertainment, and advertisements from your web browser. '; Left := ScaleX(8); Top := ScaleY(96); Width := ScaleX(412); Height := ScaleY(39); end; { Label5 } Label5 := TLabel.Create(WizardForm); with Label5 do begin Parent := ISCustomPage4.Surface; Caption := 'Adobe AIR:'; Font.Color := clWindowText; Font.Height := -11; Font.Name := 'Tahoma'; Font.Style := [fsBold]; ParentFont := False; Left := ScaleX(8); Top := ScaleY(152); Width := ScaleX(63); Height := ScaleY(13); end; { Label6 } Label6 := TLabel.Create(WizardForm); with Label6 do begin Parent := ISCustomPage4.Surface; Caption := 'Adobe AIR is a cross-operating-system runtime that lets developers combine HTML, ' + #13#10 + 'JavaScript, Adobe Flash® and Flex technologies, and ActionScript®; and also lets ' + #13#10 + 'users to deploy rich Internet applications (RIAs) on a broad range of devices including ' + #13#10 + 'desktop computers, netbooks, tablets, smartphones, and TVs. '; Left := ScaleX(8); Top := ScaleY(168); Width := ScaleX(415); Height := ScaleY(52); end; with WizardForm.MainPanel do begin Left := ScaleX(0); Top := ScaleY(0); end; with WizardForm.PageDescriptionLabel do begin Transparent := True; Left := ScaleX(24); Top := ScaleY(29); end; with WizardForm.PageNameLabel do begin AutoSize := True; Left := ScaleX(16); Top := ScaleY(8); Width := ScaleX(4); end;{ ReservationBegin } // This part is for you. Add your specialized code here.{ ReservationEnd }end;// Don't modify this section. It is generated automatically.{ RedesignWizardFormEnd } // Don't remove this line!procedure ISCustomPage1Activate(Sender: TWizardPage);beginend;procedure iswin7_add_glass(Handle:HWND; Left, Top, Right, Bottom : Integer; GDIPLoadMode: boolean);external 'iswin7_add_glass@files:iswin7.dll stdcall';procedure iswin7_add_button(Handle:HWND);external 'iswin7_add_button@files:iswin7.dll stdcall';procedure iswin7_free;external 'iswin7_free@files:iswin7.dll stdcall';procedure InitializeWizard();begin RedesignWizardForm; iswin7_add_button(WizardForm.BackButton.Handle); iswin7_add_button(WizardForm.NextButton.Handle); iswin7_add_button(WizardForm.CancelButton.Handle); iswin7_add_glass(WizardForm.Handle, 0, 0, 0, ScaleY(50), True);end;procedure DeinitializeSetup();begin iswin7_free;end; So, At the time of installation, I want to do the following things if the user selects the component named 'flashplugin':Check whether the process 'chrome.exe' & 'firefox.exe' is running, and show a message box if it is running. If google chrome is running, The message box should show 'Google Chrome is running. please close it or else the setup will close it automatically'; and if Firefox is running the messsage box should show 'Mozilla Firefox is running. please close it or else the setup will close it automatically'. If the user chooses OK and still any of the processes are open, the setup should kill it automatically.Please add the code for this into my script. If this isnt possible inno atleast this:Check whether the process 'chrome.exe' & 'firefox.exe' is running, and show a message box if it is running. If google chrome is running, The message box should show 'Google Chrome is running. please close it or else the setup will close it automatically'; and if Firefox is running the messsage box should show 'Mozilla Firefox is running. please close it or else the setup will close it automatically'. If the user chooses OK and still any of the processes are open, the setup should kill it automatically. A million thanks Edited November 21, 2014 by niTe_RiDeR_Pro HJSC and alfreire 2 Quote
Kelsenellenelvian Posted December 16, 2015 Posted December 16, 2015 not helfulNeither is your post alfreire 1 Quote
f483755 Posted February 16, 2016 Posted February 16, 2016 Thanks for your solution. There are two problems 1) EnumProcessModules can only access x86 processes if run in Wow3264 2) Depending on OS some of the functions are either defined in psapi.dll or kernel32.dll Here is an enhancement snippset: // Kernel32.dll on Windows 7 and Windows Server 2008 R2; // Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2; // Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP function GetProcessImageFileNamePsapi(hProcess : HANDLE; lpFilename : LPTSTR; nSize : DWORD) : DWORD; external 'GetProcessImageFileNameA@psapi.dll stdcall delayload'; function GetProcessImageFileNameKernel32(hProcess : HANDLE; lpFilename : LPTSTR; nSize : DWORD) : DWORD; external 'GetProcessImageFileNameA@kernel32.dll stdcall delayload'; ... try iLength := GetProcessImageFileNamePsapi(hProcess, lpFilename, Length(lpFilename)); except iLength := GetProcessImageFileNameKernel32(hProcess, lpFilename, Length(lpFilename)); end; Quote
Yaliang Posted February 18, 2016 Author Posted February 18, 2016 On 2016/2/16 at 11:24 PM, f483755 said: Thanks for your solution. There are two problems 1) EnumProcessModules can only access x86 processes if run in Wow3264 2) Depending on OS some of the functions are either defined in psapi.dll or kernel32.dll Here is an enhancement snippset: // Kernel32.dll on Windows 7 and Windows Server 2008 R2; // Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2; // Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP function GetProcessImageFileNamePsapi(hProcess : HANDLE; lpFilename : LPTSTR; nSize : DWORD) : DWORD; external 'GetProcessImageFileNameA@psapi.dll stdcall delayload'; function GetProcessImageFileNameKernel32(hProcess : HANDLE; lpFilename : LPTSTR; nSize : DWORD) : DWORD; external 'GetProcessImageFileNameA@kernel32.dll stdcall delayload'; ... try iLength := GetProcessImageFileNamePsapi(hProcess, lpFilename, Length(lpFilename)); except iLength := GetProcessImageFileNameKernel32(hProcess, lpFilename, Length(lpFilename)); end; thank you. Your problems and solutions are very helpful. When I write the code, I just on Win7_x86 OS. alfreire 1 Quote
Yaliang Posted February 18, 2016 Author Posted February 18, 2016 On 2014/11/21 at 1:17 PM, niT3_RiDeR_Pr0 said: Hi, here is my script: Hidden Content hi,too late to replay. hope you finished your problems.:) alfreire 1 Quote
Yaliang Posted February 18, 2016 Author Posted February 18, 2016 On 2015/12/16 at 10:01 PM, gsmtamil said: not helful sorry to head that alfreire 1 Quote
Yaliang Posted February 18, 2016 Author Posted February 18, 2016 On 2015/12/16 at 1:24 AM, Kelsenellenelvian said: Neither is your post Maybe it is helpful for someone. alfreire 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.