I found this somewhere (don't remember where). It's small and works great. Basically, set the caption of _screen in your app and check for it:
IF CheckWin('My Application')
MESSAGEBOX('Application is already running.'+CHR(13);
+'Please check your taskbar for the app'+CHR(13);
+'and click on its button to maximize it.' ,48,'Application is already running!')
RETURN .F.
ENDIF
*--Remember to set the caption in your app AFTER you check for it using checkwin
*--or it will see itself running and checkwin will return positive
_screen.caption="My Application"
FUNCTION CheckWin
* Routine which sees if an application is active by looking for its
* Window title
* expC1 Window title
PARAMETER tcTitle
DECLARE INTEGER FindWindow in Win32API as FindWindow STRING, STRING
RETURN IIF(FindWindow(0,tcTitle)>0,.T.,.F.)
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"