LISTA DE APLICACIONES

sgomez
05 de Mayo del 2004
¿alguien sabe como obtener una lista de todos los programas que se están ejecutando en windows?

En realidad lo que quiero hacer yo, a partir de esta lista, es ver si el programa hecho en visual fox que quiero ejecutar, no se esté ejecutando ya en otra ventana, en cuyo caso quiero arrojar un mensaje en pantalla.

Desde ya gracias a todos.

sgomez
05 de Mayo del 2004
Me contesto a mi mismo ya que encontré la forma de hacerlo y lo publico para que si a alguien le sirve lo utilice. Ahí vá el codigo:

DECLARE Integer SetForegroundWindow IN WIN32API Integer nHwnd
DECLARE INTEGER FindWindow IN WIN32API STRING cClassName, STRING cWindName
DECLARE Integer GetWindow IN WIN32API Integer nHwnd,Integer nCmd
DECLARE Integer GetWindowText IN WIN32API Integer nhWnd, String @cString, Integer nMaxCount
DECLARE Integer GetWindowTextLength IN WIN32API Integer nWnd

#define GW_HWNDFIRST 0
#define GW_HWNDLAST 1
#define GW_HWNDNEXT 2
#define GW_HWNDPREV 3
#define GW_OWNER 4
#define GW_CHILD 5
#define GW_MAX 5


nFoxHwnd = FindWindow( 0, _SCREEN.Caption )

*** Esta será la primera ventana
nCurrWnd = GetWindow( nFoxHwnd, GW_HWNDFIRST )

*** Recorrer todas las ventanas
DO WHILE nCurrWnd # 0
*** Tamaño del título
nLength = GetWindowTextLength( nCurrWnd )
IF nLength > 0
*** Preparar un buffer para el título
cTmp = REPLICATE( CHR(0), nLength + 1 )
*** Obtener el título
=GetWindowText( nCurrWnd, @cTmp, nLength + 1 )
*** Si el handle es distinto
*** y el título igual
IF nFoxHwnd != nCurrWnd AND _SCREEN.Caption == SUBSTR( cTmp, 1, nLength )
*** Activar la otra ventana
*** y terminar la ejecución
=SetForegroundWindow( nCurrWnd )
QUIT
ENDIF
ENDIF
*** Obtener la siguiente ventana
nCurrWnd = GetWindow( nCurrWnd, GW_HWNDNEXT )
ENDDO