VISTA - how to avoid double start of programs

VISTA - how to avoid double start of programs

Postby Otto » Mon Sep 18, 2006 7:16 am

In VISTA FW - FWH programs can be started twice.
How to detect if an app is allready running?

Thanks in advance
Otto
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Sep 18, 2006 7:56 am

Otto,
Code: Select all  Expand view
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: betoncu, Google [Bot] and 83 guests

cron