coms between two applications
-
Hi I have two applications - one written in c (dos window), the other in VC++, which need to communicate a variable value to each other. I currently do this by writing the value into a file from one application, and then reading it back in the other application. This all works, but I was wondering whether there is a more elegant way of doing this? Anyone help? Thanks Mike
-
Hi I have two applications - one written in c (dos window), the other in VC++, which need to communicate a variable value to each other. I currently do this by writing the value into a file from one application, and then reading it back in the other application. This all works, but I was wondering whether there is a more elegant way of doing this? Anyone help? Thanks Mike
There are several forms of Interprocess Communication (IPC). For example: clipboard, DDE,
WM_COPYDATA
, pipes, sockets, RPC. What you have will probably work as long as you don't encounter the reader/writer problem.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
-
There are several forms of Interprocess Communication (IPC). For example: clipboard, DDE,
WM_COPYDATA
, pipes, sockets, RPC. What you have will probably work as long as you don't encounter the reader/writer problem.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
Thanks for your help What I have done is writen the data into a tempory file, and then renamed it to the actual file name that is required - this does appear to get over any file sharing problems that may have been encountered, and does work. The old C program that I have is written using Quick C, and (as far as I know) is unable to respond to Windows Messages, or use the clipboard, sockets, etc. In the VC app, I have set up a timer, which checks every 500mS (this is fast enough) to see if the file is there - if it is, it reads in the data. I am happy with the way the apps work at the moment, I just wanted to use a neater method of doing this, if possible. Mike
-
Thanks for your help What I have done is writen the data into a tempory file, and then renamed it to the actual file name that is required - this does appear to get over any file sharing problems that may have been encountered, and does work. The old C program that I have is written using Quick C, and (as far as I know) is unable to respond to Windows Messages, or use the clipboard, sockets, etc. In the VC app, I have set up a timer, which checks every 500mS (this is fast enough) to see if the file is there - if it is, it reads in the data. I am happy with the way the apps work at the moment, I just wanted to use a neater method of doing this, if possible. Mike
You might want to look into the ReadDirectoryChanges function for your 32-bit application, so your timer does not have to exist. Your program will be 'signaled' when the file appears in the folder, assuming you totally control access to the folder itself - meaning, do not choose a common folder that gets a lot of activity, or your program will be notified for every file change. People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
-
You might want to look into the ReadDirectoryChanges function for your 32-bit application, so your timer does not have to exist. Your program will be 'signaled' when the file appears in the folder, assuming you totally control access to the folder itself - meaning, do not choose a common folder that gets a lot of activity, or your program will be notified for every file change. People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
But be careful if you are looking for changes on remote (network) shares. Both
ReadDirectoryChangesW(...)
andFindFirstChangeNotification(...)
may experience problems when working with network shares - regarding path lengths and/or the remote system might not support notification of filesystem changes in such a manner. (Experienced this myself more than one time.) IOW, if your application could be working with remote filesystems, it should have a polling interval as a fallback as well. Nothing worse than getting a call first thing in the morning from a site saying that your "real-time file processing application" stopped working this morning (they upgraded a *nix box that hosted one of the shares used the previous evening, and its network file support was slightly broken). Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)