Pass data between 2 applications....

lidds

Well-known member
Joined
Oct 19, 2004
Messages
122
Programming Experience
Beginner
I have 2 stand alone applications in VB.Net, and I want to be able to pass data between both applications e.g.

Senario 1
1) App A will send data to App B
2) App B will then uses this data and write to MS SQL Server

Senario 2
1) App B will send data to App A
2) App A will then use this data.

Both applications need to be able to send and receive data.

I have been looking on the internet and have found a couple of ways of doing this, however I am quite new to the whole VB.Net / programming and I really need some guidance on the most efficient and stable way, and a way that is quite simple to implement (if there is such a process :eek:) )

Could someone please help me in suggesting a way of doing this and possible some guidance with regards to code examples?

Thanks in advance

Simon
 
Will both applications reside on the same machine, or do you need to also include the ability for passing this data over a network to the individual client machines?
 
It's a bit of a "novel" approach, but I have seen this problem met several times simply by writing small data files to a local directory that the other application is watching.

So, ApplicationA may have some information to pass to ApplicationB, it would write this data out to a file in say, ApplicationA\Output\.

ApplicationB would be setup to use a FileSystemWatcher on the folder ApplicationA\Output and when seeing this new file, would act accordingly by opening it, and reading the data.

ApplicationB would of course act in a similar manner to pass info to ApplicationA.

There are more robust approaches available, but I have seen this very simple implementation work on very rapid i/o situations.
 
The developer who is writing App A for me has suggested using windows message, and using a hidden form in both App A and App B to handle the message transfers. This sounds fine to me, and he has said that this is not probably the cleanest way at the moment, however I have a deadline for a presentation so I just need something to work for the moment.

The problem that I have got is that I am unsure of how to implement his suggestion with regards to the coding side of things, I am very new to the window message and coding in general, and I would really appreciate all help.

Below is his email:
Plan to pass data between applications:

Create windows , visible but with no area. X & Y = 1 or 0 . your window will have the title "Simon101" and class name "CLSSIMON101".
In my application my window title will be "Simon202", and a class name of "CLSSIMON202". From this we can search and always find each
window in either application.

Message scheme for data transfer . In each window we will implement a windows standard message WM_COMMAND .
all window massages have an associated WPARAM and a LPARAM. the LOWORD of the WPARAM
will contain sub-messages here are some of those and the values:

_CMD_BEGIN = 1
_CMD_END =2
_CMD_CAMORIGIN =3
_CMD_CAMTARGET =4
_CMD_OBJINDEX =5
_CMD_OBJORIGIN =6

The HIWORD of WPARAM will contain these sub instructions

_CMD_XVALUE =1 -- a float
_CMD_YVALUE= 2 -- a float
_CMD_ZVALUE =3 -- a float
_CMD_LONG =4
_CMD_FLOAT =5
_CMD_INT =6


The LPARAM will contain whatever data not as a pointer, but as static data, I use this method because this will eliminate memory issues..


example 1 message procedure chain
send start message
1- WM_COMMAND, MAKELONG(_CMD_BEGIN,0) , WPARAM(0,0), LPARAM(0)
send origin takes 3 message
2- WM_COMMAND, WPARAM(_CMD_CAMORIGIN,_CMD_XVALUE) , LPARAM(1234.0)
3- WM_COMMAND, WPARAM(_CMD_CAMORIGIN,_CMD_YVALUE) , LPARAM(2344.0)
4- WM_COMMAND, WPARAM(_CMD_CAMORIGIN,_CMD_ZVALUE) , LPARAM(1.0)
send end message
5- WM_COMMAND, MAKELONG(_CMD_END,0) , WPARAM(0,0), LPARAM(0)

example 2 message procedure chain
send start message
1- WM_COMMAND, MAKELONG(_CMD_BEGIN,0) , WPARAM(0,0), LPARAM(0)
send position takes 3 message
2- WM_COMMAND, WPARAM(_CMD_CAMORIGIN,_CMD_XVALUE) , LPARAM(1234.0)
3- WM_COMMAND, WPARAM(_CMD_CAMORIGIN,_CMD_YVALUE) , LPARAM(2344.0)
4- WM_COMMAND, WPARAM(_CMD_CAMORIGIN,_CMD_ZVALUE) , LPARAM(1.0)
send target takes 3 message
5- WM_COMMAND, WPARAM(_CMD_CAMTARGET,_CMD_XVALUE) , LPARAM(2234.0)
6- WM_COMMAND, WPARAM(_CMD_CAMTARGET,_CMD_YVALUE) , LPARAM(3344.0)
7- WM_COMMAND, WPARAM(_CMD_CAMTARGET,_CMD_ZVALUE) , LPARAM(100.0)
send index takes 1 message
8- WM_COMMAND, WPARAM(_CMD_OBJINDEX, _CMD_INT), LPARAM(5062300)
send end message
9- WM_COMMAND, MAKELONG(_CMD_END,0) , WPARAM(0,0), LPARAM(0)

Thanks in advance

Simon
 
Back
Top