Link to home
Start Free TrialLog in
Avatar of dorinda
dorinda

asked on

Pass Data between separate exe's

I currently am passing data between two exe via temporary files that I create.  I would like to eliminate the need for the temporary files and pass the data in memory.  Is this possible? If so, how would I begin.  A small sample of two exe's sending data back and forth on the same PC would be appreciated.
Avatar of wpsjr1
wpsjr1

There are three methods that come to mind to pass data between two applications.  SendMessage with WM_COPYDATA, which requires subclassing to get notification of the incomming message.  Memory mapped files which allow for sharing of memory between two apps.  And last, an AX EXE server.  The AX EXE can be accomplished with native VB code.  If you've done some subclassing SendMessage is probably the simplest.  Have you ever done any subclassing/api?
Avatar of Ryan Chong
Hi, here is another one from MSDN:

HOWTO: Pass String Data Between Applications Using SendMessage

http://support.microsoft.com/support/kb/articles/Q176/0/58.asp


Or how about plain old DDE, or IP sockets.

Both are widely documented, compatible with other apps, applicable in local and networked environments and free with VB.
then you can try Winsock or MSComm Control to handle this.
Errr,  Winsock is OK, but MSComm ???
As my slight comment, MSComm Control can be use to transmit data via its serial post.

From MSDN:
The MSComm control provides serial communications for your application by allowing the transmission and reception of data through a serial port.

I'd create some protocols using MSComm control to receive and transfer data when i was in college. So that's my opinion about using MSComm but it could be a bad solution..

OK, I was lead astray - by the original request to pass data between apps - as it seems a bit over the top to use 2x serial ports to talk between two apps on the same machine!

Let's fall-back to the other alternatives DDE & Sockets

Tally-Ho !
ASKER CERTIFIED SOLUTION
Avatar of glass_cookie
glass_cookie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If one of your exes is ActiveX exe (server) and another is standard exe(client) you can pass your data from client to server and backwards as parameters in methods and properties. It works well with simple data types and arrays of fixed and varying length.
Here is an example:
-------------------
Server exe has a class named C1
which has method getArray which returns data from server
as an array of varying length:

Public Sub getArray(A() as long,  UboundA as long)
'UboundA  - Upper index of array A
UboundA =10
redeem A(UboundA )

for i=1 to UboundA
'  .... Initializing of array A
next i
end sub
------------------
Client then makes call:
dim P() as long
dim n as long

C1.getArray(p(),n)

and then it gets data in P
To send data from client is even more simple.
 
<ping>
Avatar of dorinda

ASKER

I like the winsock sample from glass_cookie.
DORINDA or GLASS_COOKIE

Please Copy / Paste the code if you will.. <smile>>