Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to know in VFP wich programs are running in Windows
Message
From
07/09/2000 11:26:29
 
 
To
07/09/2000 04:23:47
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00413353
Message ID:
00413558
Views:
14
Hi

You could have an application that fires a timer every couple of second,and runs the code below.

This cose generate a list of running applications on a computer.

So every time the timer fires you can collect the names of the running applications, store them somewhere, then when the timer fires again

Check to see if the list of running applications has changed or is the same.
This way you can time when programs opend and when they were shutdown.

Here is the code.... it may need some changes to get it to do what you need.

SET EXCLU OFF

LOCAL awin_apps, vfp_handle, ln_current_window,ln_window_count
* Dimension array awin_apps to store running apps

* 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=1
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_current_window=GetWindow(ln_current_window,2)
DIMENSION awin_apps(ln_window_count,2)
awin_apps[ln_Window_Count,1]=lc_window_title
awin_apps[ln_Window_Count,2]=ALLTRIM(STR(ln_current_window))

ln_window_count=ln_window_count+1


ENDIF
** Call to GetWindow to fetch handle of running applications.
ln_current_window=GetWindow(ln_current_window,2)

ENDDO
DISPLAY MEMORY LIKE awin_apps TO FILE c:\apps.txt
MODI FILE c:\apps.txt



Hope this helps

Steven Bowskill
Previous
Reply
Map
View

Click here to load this message in the networking platform