Hello,
A FW16 application can't be run twice on a PC, unless it is run in different parts of the memories (properties of shortcut).
How can I prevent that a FW32 application is run twice ?
Thanks.
Michel
How prevent running an application twice ?
How prevent running an application twice ?
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Code: Select all | Expand
#include "FiveWin.ch" #define GW_CHILD 5 #define GW_HWNDNEXT 2 function Main() local oWnd if Is Exe Running( cFileName( HB_ARGV( 0 ) ) ) ShowApplication() else DEFINE WINDOW oWnd TITLE "Test" ACTIVATE WINDOW oWnd endif return nil function ShowApplication() local hWnd := FindWnd( cFileNoExt( HB_ARGV( 0 ) ) ) if hWnd != nil SetForeGroundWindow( hWnd ) endif return nil function FindWnd( cTitle ) local hWnd := GetWindow( GetDesktopWindow(), GW_CHILD ) while hWnd != 0 if Upper( cTitle ) $ Upper( GetWindowText( hWnd ) ) return hWnd endif hWnd = GetWindow( hWnd, GW_HWNDNEXT ) end return nil
- Enrico Maria Giordano
- Posts: 8767
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 5 times
- Contact:
Antonio Linares wrote:Code: Select all | Expand
if Is Exe Running( cFileName( HB_ARGV( 0 ) ) )
IsExeRunning()

EMG
Thanks guys.
You were a great help.
My questions has been answered greatfully.
Regards,
Michel
You were a great help.
My questions has been answered greatfully.
Regards,
Michel
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
I'm using this code because sometimes HB_ARGV(0) acts weird on some computers, ie. slow start, my app can run twice, etc.
Code: Select all | Expand
IF IsExeRunning(cFileName(GetModuleFileName(GetInstance()))) //cFileName(HB_ARGV(0)) msgalert("Program already running!"+CRLF+"This program cannot be started more than one instance!") QUITENDIF