Microsoft KB Archive/108681

From BetaArchive Wiki

Using DDE to Check If Another Windows Application Is Open

ID: Q108681



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b



When you are using dynamic data exchange (DDE) commands programmatically, there may be times when you have to determine if a session of an application is already running. DDESetOption() and DDEInitiate() can be used determine if a application is running or not.

For example, the following code determines if Microsoft Excel is already open:

   =DDESetOption("Safety",.f.)         && This turns off the message box
                                       && so that the program will
                                       && not be interrupted.
   openapp=DDEInitiate("Excel","System")

   IF openapp < 0                       && Any negative number returned
                                        && by DDEInitiate() means that a
                                        && channel could not be opened.
      RUN/N C:\EXCEL\EXCEL.EXE
   ENDIF 

Additional query words: VFoxWin FoxWin 2.50

Keywords          : FxinteropDde 
Version           : 2.50 2.50a 2.50b
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: August 10, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.