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
#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
Antonio Linares wrote:
- Code: Select all Expand view
if Is Exe Running( cFileName( HB_ARGV( 0 ) ) )
IF IsExeRunning(cFileName(GetModuleFileName(GetInstance()))) //cFileName(HB_ARGV(0))
msgalert("Program already running!"+CRLF+"This program cannot be started more than one instance!")
QUIT
ENDIF
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 70 guests