*========================================================================== *-- Title......: DDEServe *-- Abstract...: Procedure to detect if another instance of the application *-- : already exists. If so, that instance is maximised and this *-- : instance is closed. If no detected, then the DDE Server is *-- : set up and the application continues. *-- Parameters.: name of EXE file *========================================================================== * procedure DDEServe parameters ; tcExeName * #define sSYSTEM "SYSTEM" #define sDEFINE "DEFINE" #define sSAFETY "SAFETY" * if empty(tcExeName) wait window "name of EXE file not passed to DDEServer." * else private ; jnChannel * *** Don't show warning dialog if server not found * = DDESetOption(sSAFETY, .f.) * *** Try to establish a link to the DDE server * jnChannel = DDEInitiate(tcExeName, sSYSTEM) * *** If found cancel * if jnChannel # -1 = DDETerminate(jnChannel) cancel * endif * *** Set up new DDE server * = DDESetService(tcExeName, sDEFINE) * *** Create the topic name for the Detected function * = DDESetTopic(tcExeName, sSYSTEM, "Detected") * endif * return * * *========================================================================== *-- Title......: DDEReset *-- Version....: 1.0 A *-- Abstract...: Procedure to reset the DDE server set up in DDEServe *-- Parameters.: name of EXE file *========================================================================== * procedure DDEReset parameters ; tcExeName * if empty(tcExeName) wait window "EXE name not passed to DDEReset" * else * *** Reset DDE server * = DDESetService(tcExeName, "RELEASE") * endif * return * * *========================================================================== *-- Title......: Detected *-- Abstract...: Procedure to maximise the application. Used in DDEServe *-- Parameters.: None used, however, parameters must be specified since the *-- : DDE sends values. *========================================================================== * function Detected parameters ; tnChannel, ; tcAction, ; tcItem, ; txData, ; txFormat, ; tnAdvise * zoom window screen max * return .t. * * *-------------------------------------------------------------------------- *--------------------------------------------------------------------------