Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to send message to another EXE?
Message
De
23/06/2000 11:56:48
 
 
À
21/06/2000 11:49:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00382726
Message ID:
00383822
Vues:
14
>Hi,
> I have 2 EXE, AppA.exe and AppB.exe.
> I need to send cetain value to AppB from AppA in order to close the AppB conditionally. Any idea?
>
>Thank you

The easiest way is to use DDE. Set up app A as a DDE server and app B
as a client.
LOCAL cDDEServerName
cDDEServerName = "MyDDeServer"

*** Set up the server ***
=DDESetOption('SAFETY', .F.) 
=DDESetService(cDDEServerName, 'DEFINE')
=DDESetService(cDDEServerName, 'EXECUTE', .T.)
=DDESetTopic(cDDEServerName, 'DO', 'DDE_Execute')

PROCEDURE DDE_Execute
          LPARAMETERS tnChannel, tcAction, tcItem, tcData, tcFormat, tnAdvise
          LOCAL lResult
          DO CASE
             CASE tcAction = 'INITIATE'
                  lResult = .T.

             CASE tcAction = 'EXECUTE' .AND. tcData = 'MYCOMMAND'
                  *** This is the code the client invokes *** 
                  =MESSAGEBOX('Hello, world')
                  lResult = .T.

             CASE tcAction = 'TERMINATE'
                  lResult = .T.
          ENDCASE
          
          RETURN lResult
ENDPROC

*** Set up the client ***
LOCAL cDDEServerName, nDDEChannel
cDDEServerName = "MyDDeServer"

nDDEChannel = DDEInitiate(cDDEServerName, 'DO')
IF nDDEChannel > 0
   *** Send your message here ***
   =DDEExecute(nDDEChannel, 'MYCOMMAND')
   =DDETerminate(nDDEChannel)
ENDIF
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform