ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Fermeture d'une application Windows depuis VFP   



L'auteur

EmanuelL
Suisse Suisse
Membre Simple
# 0000000058
enregistré le 21/10/2004

http://fiduconsult.ch

Fiche personnelle


Note des membres
pas de note

Contributions > 05 - API et appels systèmes

Fermeture d'une application Windows depuis VFP
# 0000000295
ajouté le 28/02/2006 11:25:14 et modifié le 28/02/2006
consulté 8860 fois
Niveau initié

Version(s) Foxpro :
VFP 9.0
VFP 8.0
VFP 7.0
VFP 6.0

Description

Fonction permattant depuis VFP la fermeture d'une application Windows ouverte, présente sur Applications de Gestionnaire des tâches de Windows, par son nom.

Testée sous Windows 2000 et XP.

Code source :
*-- Test
CloseWinApp("Adobe Reader")

*-------------------------------------------------
*-- Fermeture d'une application Windows ouverte
FUNCTION CloseWinApp(tcTitle)
   DECLARE INTEGER GetActiveWindow IN Win32API

   DECLARE INTEGER GetWindowText IN Win32API;
      INTEGER HWND,;
      STRING @cText,;
      INTEGER nType

   DECLARE INTEGER GetWindow IN Win32API;
      INTEGER HWND,;
      INTEGER nType

   DECLARE INTEGER SendMessage IN Win32API;
      INTEGER HWND,;
      INTEGER uMsg,;
      INTEGER wParam,;
      INTEGER LPARAM

   #DEFINE WM_CLOSE 0x0010

   hNext = GetActiveWindow() && Current app's window

   * Iterate through the open windows
   DO WHILE hNext # 0
     cText = REPLICATE(CHR(0),80)
     GetWindowText(hNext,@cText,80) && Get window title

     * parameter text is present in window title
     IF UPPER(ALLTRIM(tcTitle)) $ UPPER(cText)
       SendMessage(hNext,WM_CLOSE,0,0)
       EXIT
     ENDIF

     hNext = GetWindow(hNext,2) && Next window
   ENDDO
ENDFUNC

Commentaires
Aucun commentaire enregistré ...

Publicité

Les pubs en cours :


www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3