Home » U++ Library support » TopWindow&PopUp, TrayIcon » How to check whether application is running
Re: How to check whether application is running [message #27875 is a reply to message #27874] |
Mon, 09 August 2010 04:16 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
I´ve been proceeding as follows:
// global function:
HWND GetRunningWindow() {
// Check if exists an application with the same TITLE as this application
HWND hWnd = FindWindow(NULL, "My TopWindow Title");
if (IsWindow(hWnd)) {
HWND hWndPopup = GetLastActivePopup(hWnd);
if (IsWindow(hWndPopup))
hWnd = hWndPopup; // Previous instance exists
} else {
hWnd = NULL; // Previous instance doesnt exist
}
return hWnd;
}
GUI_APP_MAIN
{
// Checks for previous instance of our app
HWND hOtherWnd = GetRunningWindow();
// Allow only one app instance
if (hOtherWnd) {// hOtherWnd != NULL -> Previous instance exists
PromptOK("The program is already running");
SetForegroundWindow(hOtherWnd); // Activate it &
if (IsIconic(hOtherWnd))
ShowWindow(hOtherWnd, SW_RESTORE); // restore it
return; // Abort current app execution
}
// ... otherwise, run app here ...
}
Thanks again.
[Updated on: Mon, 09 August 2010 04:29] Report message to a moderator
|
|
|
|
|
How to check whether application is running
By: bushman on Mon, 09 August 2010 03:59
|
|
|
Re: How to check whether application is running
By: bushman on Mon, 09 August 2010 04:16
|
|
|
Re: How to check whether application is running
|
|
|
Re: How to check whether application is running
By: bushman on Mon, 09 August 2010 05:18
|
|
|
Re: How to check whether application is running
|
|
|
Re: How to check whether application is running
By: unodgs on Tue, 10 August 2010 22:47
|
|
|
Re: How to check whether application is running
By: kohait00 on Fri, 13 August 2010 16:21
|
|
|
Re: How to check whether application is running
By: Alboni on Wed, 16 January 2013 12:29
|
|
|
Re: How to check whether application is running
By: lectus on Wed, 16 January 2013 14:38
|
|
|
Re: How to check whether application is running
By: Alboni on Wed, 16 January 2013 15:44
|
|
|
Re: How to check whether application is running
|
|
|
Re: How to check whether application is running
By: lectus on Fri, 18 January 2013 01:56
|
|
|
Re: How to check whether application is running
|
|
|
Re: How to check whether application is running
By: Alboni on Wed, 16 January 2013 17:38
|
|
|
Re: How to check whether application is running
By: Alboni on Wed, 16 January 2013 18:01
|
|
|
Re: How to check whether application is running
By: BioBytes on Wed, 16 January 2013 21:32
|
Goto Forum:
Current Time: Thu May 09 03:53:31 CEST 2024
Total time taken to generate the page: 0.02806 seconds
|