Results 1 to 13 of 13

Thread: [RESOLVED] [2005] DDE In VB.NET

  1. #1

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Resolved [RESOLVED] [2005] DDE In VB.NET

    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?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] DDE In VB.NET

    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

  3. #3

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] DDE In VB.NET

    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?

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] DDE In VB.NET

    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.

  5. #5

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] DDE In VB.NET

    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.

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] DDE In VB.NET

    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?

  7. #7

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] DDE In VB.NET

    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...

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] DDE In VB.NET

    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?

  9. #9

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] DDE In VB.NET

    So how would I pass the arguments to the first instance using Application.StartupNextInstance?

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] DDE In VB.NET

    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?

  11. #11

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] DDE In VB.NET

    I think so...

    Do you have a small example of this? In VB 2005 My.Application.StartupNextInstance does not appear to be valid...

  12. #12
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] DDE In VB.NET

    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.

  13. #13

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] DDE In VB.NET

    Awesome! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width