I remember a LONG time ago that I was able to create DDE "channels" between two applications. Is that still possible with .Net? If so does anyone have any examples or articles I could read about this?
Printable View
I remember a LONG time ago that I was able to create DDE "channels" between two applications. Is that still possible with .Net? If so does anyone have any examples or articles I could read about this?
I think there was some work done at some point to try to make a wrapper to easily use DDE in .NET but I am not sure if it ever surfaced.
Most (if not all) DDE stuff has been replaced by remoting or WCF
So if I need to send data between two applications without file and/or registry access how would I do that running the .NET 2.0 framework without DDE?
There are a few ways
1) Using .NET Remoting
2) Using Win API SendMessage/Copy Memory calls (more complex)
.NET remoting has some nice classes, like the IPC protocol classes, which is InterProcess Communication.
I went through the tutorial at http://msdn.microsoft.com/en-us/libr...2e(VS.71).aspx
The main thing I do NOT like it the need of having a .config file. Is there anyway to do .Net remoting without having to have a .config?
Also does anyone have an example of using .Net Remoting. Just need something to learn from.
Thanks.
what operating systems are you targetting, and also, is the communication between apps supposed to be 2 way, and is it supposed to be across computers or just across apps?
It is only going to be done on a single workstation targeting Windows XP:
Basically I have an app that is running on a workstation. If the app is executed a second time with a command line switch it sends a message to the first instance of the app with the command line information to execute.
Example:
app.exe /switch "Message"
This will tell the first instance of the app to evaluate the message and show it. Though a "DDE" channel.
I hope I explained that correctly...
So is it supposed to be single instance then? Only 1 instance should run at a given time, and if a second instance is launched with command line params, it should send those to the first instance?
That functionality is built right into the application framework for VB, which features events like ApplicationStartup and ApplicationStartupNextInstance.
Is that what you are looking for? or something else?
So how would I pass the arguments to the first instance using Application.StartupNextInstance?
Thats the point, you don't have to. StartupNextInstance fires in the FIRST instance, when the SECOND instance is opened, bring with it the command line params passed to the second instance, so the first instance can handle them.
Make sense?
I think so...
Do you have a small example of this? In VB 2005 My.Application.StartupNextInstance does not appear to be valid...
In your project, you need to go to project properties.
Once you are in the properties page, make sure the first vertical tab is selected (Application tab). it should be selected by default anyway.
In this screen, make sure the "Enable Application Framework" is checked, and under that, make sure "Make single instance application" is checked off.
After that, look down to see the button that says "View Application Events" (You might need to scroll a little)
Clicking that button brings you to a code window. Once in there, select "(MyApplication Events)" from the left drop down atop the code window, and then from the right drop down, select StartupNextInstance.
That creates the stub for the event, and you can then code in there.
Note the eventargs variable e has 2 important properties for you to use in your code here.
e.BringToForeground
and
e.CommandLine
BringToForeground is a boolean you can set to make the first instance become focused when a second instance it attempted to be launched.
CommandLine is a readonly array of strings which are the command line params used when trying to launch the second instance. They have been sent back to the first instance so you can handle them in this routine.
Awesome! Thanks!