Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two or more instances of my application
Message
From
17/11/2022 14:14:54
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01685332
Message ID:
01685365
Views:
62
using the window title as mutex works, as long as no VM or TS server is in the deck.
But as Virtualbox cost nothing but a little performance this might not hinder much.


>Hi Francisco,
>years ago (or decades?) I found this examoke which has been working fine for me (and my customers) over the years:
>
>
>LPARAMETER pctitle
>* pctitle - The title bar of the Window
>*   Note: The title does not have to be
>*   the complete title that appears
>* API Declarations
>DECLARE INTEGER GetDesktopWindow IN Win32API
>DECLARE INTEGER GetWindow IN Win32API;
>  INTEGER hwnd, INTEGER dflag
>DECLARE INTEGER GetWindowText IN Win32API ;
>  INTEGER hwnd, STRING @lptstr, INTEGER cbmax
>
>LOCAL lnhwnd, lnnext, lldone, lctitle_bar, lcsearchfor,;
>  lntext_len
>lcsearchfor = UPPER(ALLTRIM(pctitle))
>lnhwnd = GetDesktopWindow()
>lnhwnd = GetWindow(lnhwnd, 5) && Get first child window
>lnnext = 2
>lldone = .F.
>lctitle_bar = ""
>DO WHILE NOT lldone
>  IF NOT EMPTY(lnhwnd)
>    lctitle_bar = SPACE(200) + CHR(0)
>    lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
>    lctitle_bar = UPPER(LEFT(lctitle_bar, lntext_len))
>    
>    * lldone = (lcsearchfor $ lctitle_bar)  && Originalzeile
>    lldone = (lcsearchfor == lctitle_bar)
>    IF NOT lldone
>      lnhwnd = GetWindow(lnhwnd, lnnext)
>    ENDIF
>  ELSE
>    lldone = .T.
>  ENDIF
>ENDDO
>RETURN lnhwnd
>
Previous
Reply
Map
View

Click here to load this message in the networking platform