DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: opening a new file from command line in existing process

  1. #1
    Andrew Guest

    opening a new file from command line in existing process


    With Netscape or Microsoft Word, it is possible to run the
    executable from the command line (DOS box) with a file name
    as argument; e.g.,

    c:\program files\ms office\winword.exe c:\my documents\foo.doc

    and have the argument effect an already running copy of Word or
    Netscape.

    If Word is already running, a new Word window will appear with
    foo.doc but there is still only one copy of winword.exe running.

    When I watch task manager, I see that a second of winword.exe
    runs but it somehow joins the first.

    How is this done in the Microsoft Windows world with Visual C++?

    -andrew

  2. #2
    Boris Karadjov Guest

    Re: opening a new file from command line in existing process


    There is no standard mechanism to achieve such behavior. You have to implement
    it yourself. What you need to do is:

    1) When your application is started check if another copy is already running.
    You can accomplish this by using shared data sections, by looking for a specific
    window name or class, or by utilizing some form of interprocess communication.

    2) If you find such a copy, pass all information supplied on the command
    line to it and exit the more recently started copy. Of course, your application
    should be prepared to handle such notification and respond to it by creating
    a new window, loading the document specified on the command line, etc.


    Boris Karadjov
    Brainbench MVP for Visual C++
    http://www.brainbench.com


    "Andrew" <a_silins@yahoo.com> wrote:
    >
    >With Netscape or Microsoft Word, it is possible to run the
    >executable from the command line (DOS box) with a file name
    >as argument; e.g.,
    >
    >c:\program files\ms office\winword.exe c:\my documents\foo.doc
    >
    >and have the argument effect an already running copy of Word or
    >Netscape.
    >
    >If Word is already running, a new Word window will appear with
    >foo.doc but there is still only one copy of winword.exe running.
    >
    >When I watch task manager, I see that a second of winword.exe
    >runs but it somehow joins the first.
    >
    >How is this done in the Microsoft Windows world with Visual C++?
    >
    >-andrew



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center