Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To know program running
Message
De
21/04/2004 08:59:08
 
 
À
21/04/2004 03:32:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00896749
Message ID:
00896838
Vues:
13
LOCAL awin_apps, vfp_handle, ln_current_window,ln_window_count
* Dimension array awin_apps to store running apps
DIMENSION awin_apps[1,2]
* Initialize variable to store handle for current application
vfp_handle=0
* Declare API Functions
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
* End of API function declarations
* Get handle for current application
vfp_handle=FindWindow(0,_SCREEN.CAPTION)
* Store handle of current app to a variable
ln_current_window=vfp_handle
* Initialize a count variable used to dimension array of running apps
ln_window_count=0
DO WHILE ln_current_window>0
	*  Initialize variable to store application title
	lc_window_title=SPACE(255)
	* Call to GetWindowText to fetch window caption
	ln_length=GetWindowText(ln_current_window, ;
		@lc_window_title,LEN(lc_window_title))
	* Note that the lc_window_title variable is used as a buffer to
	* receive text from the call to GetWindowText
	IF ln_length>0
		lc_window_title=STRTRAN(TRIM(lc_window_title),CHR(0),"")
	ELSE
		lc_window_title=""
	ENDIF
	IF ln_current_window>0 .AND. !EMPTY(lc_window_title)
		* Increment the window count and re-dimension the array of running
		* applications
		ln_window_count=ln_window_count+1
		DIMENSION awin_apps(ln_window_count,2)
		awin_apps[ln_Window_Count,1]=lc_window_title
		awin_apps[ln_Window_Count,2]=ln_current_window
	ENDIF
	* Call to GetWindow to fetch handle of running applications.
	ln_current_window=GetWindow(ln_current_window,2)
ENDDO

LOCAL lcsafety
lcsafety=SET("SAFETY")
IF lcsafety="ON"
	SET SAFETY OFF
ENDIF

IF !FILE("openapps.dbf")
	CREATE TABLE openapps (appname c(50), nhandle N(20,0))
ELSE
	DELETE FILE openapps.DBF
	CREATE TABLE openapps (appname c(50), nhandle N(20,0))
	*USE openapps EXCLU
	*zap
ENDIF

SET SAFETY &lcsafety

IF USED('openapps')
	IF ALEN(awin_apps,1)>0
		SELECT openapps
		FOR i=1 TO ALEN(awin_apps,1)
			APPEND BLANK
			REPLACE appname WITH awin_apps[i,1]
			REPLACE nhandle WITH awin_apps[i,2]
		NEXT
	ENDIF
	BROWSE
	USE IN openapps
ENDIF
.·*´¨)
.·`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"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform