Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another app instance question
Message
 
 
À
06/03/2002 01:00:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00628296
Message ID:
00628877
Vues:
13
Thanks Elmer. I can use some of your code, along with George's suggested API call, to completely solve the problem.

>This is something that I picked up on UT several months ago and have modified. Unfortuately I do not remember who wrote it originally. It returns a list of window titles from the task list for all running tasks and processes - optionally fills an array passed by reference with Window Titles and handles. You could scan through the array and determine how many instances are running. It may be a start. HTH.
>
>
Dimension tasklist[1,2]
>?api_listapp(@tasklist)
>for i = 1 to alen(tasklist,1)
>*!* check for instances that you want
>next
>
>
FUNCTION api_ListApp
>parameters atask
>*!* pass an array by reference and it will be filled with running processes and hwnd
>
>LOCAL  lnHandle, lnCount, lcTitle, lnI, lnHFox
>
>DIMENSION laApp[1,2]
>lnHFox=0
>
>DECLARE INTEGER FindWindow ;
>	IN win32api ;
>	INTEGER nullpointer, ;
>	STRING cwindow_name
>DECLARE INTEGER GetWindow ;
>	IN win32api ;
>	INTEGER ncurr_window_handle, ;
>	INTEGER ndirection
>DECLARE INTEGER GetWindowText ;
>	IN win32api ;
>	INTEGER n_win_handle, ;
>	STRING @ cwindow_title, ;
>	INTEGER ntitle_length
>lnHFox = FindWindow(0,_SCREEN.CAPTION)
>lnHandle = lnHFox && GetWindow(lnHFox,0)
>lnCount = 0
>DO WHILE lnHandle > 0
>	lcTitle=SPACE(255)
>	lnI=GetWindowText(lnHandle, @lcTitle,LEN(lcTitle))
>	IF lnI>0
>		lcTitle=STRTRAN(TRIM(lcTitle),CHR(0),"")
>	ELSE
>		lcTitle=""
>	ENDIF
>	IF lnHandle > 0 .AND. !EMPTY(lcTitle)
>		lnCount=lnCount+1
>		DIMENSION laApp(lnCount,2)
>		laApp[lnCount,1]=lcTitle
>		laApp[lnCount,2]=lnHandle
>	ENDIF
>	lnHandle = GetWindow(lnHandle,2)
>ENDDO
>	lcString = ""
>IF ALEN(laApp,1)>0
>	FOR i=1 TO ALEN(laApp,1)
>		lcString = lcString + laApp[i,1]+CHR(13)+CHR(10)
>	NEXT
>	if type("atask[1]") <> "U"
>	  *!* array was passed by reference
>	  =acopy(laApp,atask)
>	endif
>	release laApp
>ENDIF
>RETURN lcString
>
>ENDFUNC
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform