Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to send message to another EXE?
Message
From
23/06/2000 11:56:48
 
 
To
21/06/2000 11:49:48
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00382726
Message ID:
00383822
Views:
21
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform