I use the RegisterWindowsMessage API. This lets you create a unique windows
message that will be common to both applications. The only catch is you need
to know the hWnd of the other application, I assume you know this or can find
it out somehow. It works like this.
long msg_connect = RegisterWindowsMessage("MyApplication.Connect");
long msg_transfer = RegisterWindowsMessage("MyApplication.Transfer");
long msg_close = RegisterWindowsMessage("MyApplication.Close");
Place something similar in the Visual Basic code. Then what I do is use
SendMessage to establish the connection.
long Accept = SendMessage(target_application_hwnd, msg_connect, 0, 0); // in
place of the zeroes you can pass pointers to structures of any relevant
information like a user name and password
The receiver will process the message by subclassing or overriding the
WndProc function. If it decides to accept the connection, it should return 1
or zero otherwise. The other application should then check this return value
which is why I assigned it to the variable Accept.
long Result = SendMessage(target_application_hwnd, msg_transfer, &data1,
&data2)
Where data1 and data2 are pointers to any information you want. To get a
pointer to memory that can be read by both applications use GlobalAlloc.
Finish by sending the msg_close instruction.
"juky" wrote:
Hi all,
I have 2 applications one in VB.net and the other in VC6. I need to
pass data between them. How can I do it? what's the best way to
implement such communication ?
Any comment will be appreciate.
Thank you.
Juky