Summary
Because all applications are inherently different, there is no general method for checking whether a specific application is running. Following are some methods that you can use to determine if an application is running.Synopsis
This article discusses the methods used to determine if an application is running on the target system.
Discussion
Because all applications are inherently different, there is no general method for checking whether a specific application is running. Following are some methods that you can use to determine if an application is running.
- Check whether there is a valid module handle for the application. If you can successfully retrieve a handle for a module, you know that it is loaded and running.
Before you can determine the module handle, you need to know its module name. Each module is identified by a particular name that is determined by the code for the application. The module name is often the same as the application's file name, but is not always. If you need to know the module name for an application that you did not create, you should run the application and use a program such as PView, which is included with MSVC++ 4.0, to determine the module name for the application's executable. Keep in mind that an application may have multiple executable files and may have multiple modules. So, when trying to determine the module name for a particular application, verify that the module exists just after the application is launched and just before the application terminates.
When a particular module is loaded, it has a module handle assigned dynamically by Windows, which is valid for the life of the module. Once you know the module name, you can call the GetModuleHandle API to determine its module handle and check if it is running.
- If the application has a main window, check to see if there is a valid window handle for this type of window. If you can find a valid window handle for this type of window, the application is probably running.
Windows are identified by a window class and window name. The window class is defined in the source code for the application that created it. This class name is constant for the entire life of the window and can be determined using the Spy.exe program provided with MSVC++.
The window name is the current caption (title) for the window. You can also determine the window name with the Spy.exe program. However, remember that for some windows, particularly DOS windows, this caption changes dynamically during the life of the window.
Once you know the window class and window name for a particular window, you can call the InstallScript function FindWindow to get its window handle and use this to determine if the application is running, as shown below:
#define OUTLOOK_WND_CLASS "mspim_wnd32"
function MyFunction()
begin
if FindWindow(OUTLOOK_WND_CLASS, "") then
MessageBox("Outlook is running", INFORMATION);
else
MessageBox("Outlook is not Running", INFORMATION);
endif;
end; - Determine whether the application creates any temporary files that may indicate whether it is running, and then check for the existence of these files using the InstallScript function is.
- Determine whether the application creates registry entries or .ini file entries when running, and then check for the existence of these entries using the InstallScript function RegDBKeyExist.
- If a file gets locked when a particular application is running, you can call the InstallScript function is to determine if this file is locked as a way to determine if it's running.
Additional Information
Additional information on the InstallScript functions mentioned here can be found in self-titled topics in the InstallShield Help Library. For example, information on the 'Is' function can be found in the topic Is.
Related Articles
Determining If an MSI Install Is Running with Administrative Privileges 3Number of Views Deployment Failure: No suitable deployment destination is currently available. 11Number of Views How to Programattically Determine if a New-Style InstallScript MSI is running Silently 4Number of Views Determining If a DLL or EXE Is Self-Registering 3Number of Views Check if High Availability has been enabled for SQL 254Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago