Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Test outlook open?
Message
De
07/01/2010 09:53:31
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01442564
Message ID:
01442613
Vues:
48
>is there a way to test if outlook is open before i initiate the program to send an email.
>
>a line of code that would precede this:
>loOutlook = CREATEOBJECT("outlook.application")
>
> thanks
>k

Place this code in a isRunning.prg.
* FUNCTION: Is_Run32.prg
* AUTHOR: George Tasker
* DATE: January 13, 1998 - 8:26 AM
* PURPOSE: Determines if a Windows
* application is running and returns
* the handle of the window if it is,
* otherwise returns 0. 32 bit version
* for Windows 95/NT 3.51-4
* Modified 5/20/2001 - gt

LPARAMETER pctitle

* Parameter list description
*
* pctitle - The title bar of the Window
*   Note: The title does not have to be
*   the complete title that appears
*
*
* API Declarations
DECLARE INTEGER GetDesktopWindow IN Win32API
DECLARE INTEGER GetWindow IN Win32API;
    INTEGER HWND, INTEGER dflag
DECLARE INTEGER GetWindowText IN Win32API ;
    INTEGER HWND, STRING @lptstr, INTEGER cbmax

LOCAL lnhwnd, lnnext, lldone, lctitle_bar, lcsearchfor,;
    lntext_len
lcsearchfor = UPPER(ALLTRIM(pctitle))
lnhwnd = GetDesktopWindow()
lnhwnd = GetWindow(lnhwnd, 5) && Get first child window
lnnext = 2
lldone = .F.
lctitle_bar = ""
DO WHILE NOT lldone
    IF NOT EMPTY(lnhwnd)
        lctitle_bar = SPACE(200) + CHR(0)
        lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
        lctitle_bar = UPPER(LEFT(lctitle_bar, lntext_len))
        lldone = (lcsearchfor $ lctitle_bar)
        IF NOT lldone
            lnhwnd = GetWindow(lnhwnd, lnnext)
        ENDIF
    ELSE
        lldone = .T.
    ENDIF
ENDDO
RETURN lnhwnd<>0
then call it (for example)
? isrunning("Outlook")
if Outlook is running it will return True otherwise False,
Greg Reichert
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform