Cerrar aplicaciones externas desde mi programa

30/09/2003 - 02:32 por Francesca | Informe spam
Buenas Noches,
Estoy realizando un trabajo para la universidad, es una
aplicación en VB6 que luego de un tiempo especificado por
el usuario debe cerrar de forma automática todas las
aplicaciones que se estén ejecutando en la pc, y si hay
alguna que haya quedado con modificaciones pendientes, los
cambios deben ser guardados también, ya sea en el mismo
archivo o en otro temporal, todo esto sin intervención del
usuario; los nombres de los archivos deben ser asignados
por mi aplicación. Mi consulta es cómo conseguir
identificar cada una de las apliaciones abiertas y luego
de esto, enviarles una orden de cierre especificando que
los cambios deben ser guardados (para las que lo
requieran) en la ruta indicada. Se que en VB es un poco
difícil, talvez tengan alguna sugerencia para crear un
programa en Visual C que realice esta función y que sea
llamado por mi aplicación.
Gracias de antemano por sus sugerencias!!
 

Leer las respuestas

#1 Adalberto Rua Aguirre
09/10/2003 - 16:02 | Informe spam
Hola, Francesca

Te adjunto el punto de entrada para que sigas investigando. La funcion
GetWindow te da la lista de las ventanas (aplicaciones Abiertas). Todo esto
puedes investigar en http://msdn.microsoft.com

suerte
GetWindow
The GetWindow function retrieves a handle to a window that has the specified
relationship (Z order or owner) to the specified window.

HWND GetWindow(
HWND hWnd, // handle to original window
UINT uCmd // relationship flag
);
Parameters
hWnd
Handle to a window. The window handle retrieved is relative to this
window, based on the value of the uCmd parameter.
uCmd
Specifies the relationship between the specified window and the window
whose handle is to be retrieved. This parameter can be one of the following
values. Value Meaning
GW_CHILD The retrieved handle identifies the child window at the top
of the Z order, if the specified window is a parent window; otherwise, the
retrieved handle is NULL. The function examines only child windows of the
specified window. It does not examine descendant windows.
GW_ENABLEDPOPUP Windows 2000: The retrieved handle identifies the
enabled popup window owned by the specified window (the search uses the
first such window found using GW_HWNDNEXT); otherwise, if there are no
enabled popup windows, the retrieved handle is that of the specified window.
GW_HWNDFIRST The retrieved handle identifies the window of the same
type that is highest in the Z order. If the specified window is a topmost
window, the handle identifies the topmost window that is highest in the Z
order. If the specified window is a top-level window, the handle identifies
the top-level window that is highest in the Z order. If the specified window
is a child window, the handle identifies the sibling window that is highest
in the Z order.
GW_HWNDLAST The retrieved handle identifies the window of the same
type that is lowest in the Z order. If the specified window is a topmost
window, the handle identifies the topmost window that is lowest in the Z
order. If the specified window is a top-level window, the handle identifies
the top-level window that is lowest in the Z order. If the specified window
is a child window, the handle identifies the sibling window that is lowest
in the Z order.
GW_HWNDNEXT The retrieved handle identifies the window below the
specified window in the Z order. If the specified window is a topmost
window, the handle identifies the topmost window below the specified window.
If the specified window is a top-level window, the handle identifies the
top-level window below the specified window. If the specified window is a
child window, the handle identifies the sibling window below the specified
window.
GW_HWNDPREV The retrieved handle identifies the window above the
specified window in the Z order. If the specified window is a topmost
window, the handle identifies the topmost window above the specified window.
If the specified window is a top-level window, the handle identifies the
top-level window above the specified window. If the specified window is a
child window, the handle identifies the sibling window above the specified
window.
GW_OWNER The retrieved handle identifies the specified window's
owner window, if any. For more information, see Owned Windows.


Return Values
If the function succeeds, the return value is a window handle. If no window
exists with the specified relationship to the specified window, the return
value is NULL. To get extended error information, call GetLastError.

Remarks
The EnumChildWindows function is more reliable than calling GetWindow in a
loop. An application that calls GetWindow to perform this task risks being
caught in an infinite loop or referencing a handle to a window that has been
destroyed.

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Import Library: Use user32.lib.

See Also
Windows Overview, Window Functions, EnumChildWindows

Built on Friday, May 14, 1999
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Import Library: Use user32.lib.

See Also
Windows Overview, Window Functions, EnumChildWindows


"Francesca" escribió en el mensaje
news:18fc401c386ea$4e7d2740$
Buenas Noches,
Estoy realizando un trabajo para la universidad, es una
aplicación en VB6 que luego de un tiempo especificado por
el usuario debe cerrar de forma automática todas las
aplicaciones que se estén ejecutando en la pc, y si hay
alguna que haya quedado con modificaciones pendientes, los
cambios deben ser guardados también, ya sea en el mismo
archivo o en otro temporal, todo esto sin intervención del
usuario; los nombres de los archivos deben ser asignados
por mi aplicación. Mi consulta es cómo conseguir
identificar cada una de las apliaciones abiertas y luego
de esto, enviarles una orden de cierre especificando que
los cambios deben ser guardados (para las que lo
requieran) en la ruta indicada. Se que en VB es un poco
difícil, talvez tengan alguna sugerencia para crear un
programa en Visual C que realice esta función y que sea
llamado por mi aplicación.
Gracias de antemano por sus sugerencias!!

Preguntas similares