CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Location
    CA , USA
    Posts
    83

    Question opening many docs in singleton app

    Hi


    Hi i want to open many doc files from explorer in a singleton application. I have a singleton application that is working fine(singleton is achieved using mutex). But i want to send message to that existing application when ever user tries to open many other files from the windows explorer with the file name that comes in the command line. How can i communicate bet'n processes using shared memory?? I tried using GlobalAlloc and sending the message. But it did not work.

    Any help is greately appreciated

    Shashi

  2. #2
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939
    I have done this in an app here. Instead of a mutex I used a mapped memory file that can be used between instances. When a new instance starts up, it trys to open the mapped memory file. If it doesn't exist, it creates it as its the first instance, it then populates it with the HWND of the CMainFrame window. This mapped memory file is a structure somehting like:

    struct {
    HWND window ;
    char commandline[MAX_PATH] ;
    }

    If it already existed, the new instance populates the commandLine variable in the memory mapped file and uses the HWND to send a user defines message to the other app. No parameters are passed as these are in the memory mapped file. You other instance, gets the message, read the command line from the MMF and then acts accordingly.

    Take a look at CreateFileMapping
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

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

Featured