file opened?

<deleted>

Answer this question

file opened?

  • jw700

    I have a file extension with my application on the Windows CE operating system and when I click on a file with my extension, my application starts and I get the name of the file as a command line argument using the "myexe.exe -opendoc %1" shell open command.

    but, once the application is running and I click on another file, I do not know what method to implement to catch the next file that is opened... I presume my application will be notified using the shell open command "myexe.exe %1"

    So here is my question: How do I "catch" the file that is being clicked on ( in CE ) when my application is already running

    Thanks

    Mike


  • Amos Soma

    Two reasons:

    1. Your implementation of instance count can't possibly work since even static variables are not shared across instances. You’d need to use something else, e.g. named mutex.

    1. On Windows Mobile (which you’re probably using but incorrectly call it Windows CE) NETCF enforces single instance behavior which would maximize running instance and terminate second one.


  • lou_1

    Read the entire train of thought on this... it seems like it would have just been easier to leave things alone and let the user decide if they want a singleton or not ...
  • Tinomolloy

    Please do not cross post. Merging...

  • irs

    <deleted>


  • Learning VB

    hmmm... never thought about that ... what are the draw backs
  • Drokker

    NETCF enforces that behavior per design guide lines on WM. It is important since user interface is not designed to handle it differently.



  • Nima_Don

    Thanks for the information...

    So number 1. is an easy fix.

    However, number 2 poses a problem for your initial suggestion... what do you recommend


  • Laurent87471

    You'd need to make second launched copy of your application notifying already running copy somehow. Any common IPC methods would do.



  • Jonathan Cran

    This would give you a clue (post by Michael Koster ):

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=767715&SiteID=1



  • Damir Dobric

    OK... so I thought about your proposal and made a test application that keeps track of instance count. I also put in a command line argument parameter to get the name of the file and how the application is being told to open the file

    Here is the entire program ( Form1 is the standard template form that is made when you create a new Windows CE application )

    static class Program
    {
    static int INSTANCE_COUNT = 0;
    [MTAThread]
    static void Main( string [] args )
    {
    INSTANCE_COUNT++;
    if (args != null)
    {
    string msg = "";
    msg = INSTANCE_COUNT.ToString();
    string temp = "";
    foreach( string s in args )
    {
    temp += "'" + s + "'";
    }
    if( temp != string.Empty)
    {
    msg += " File:" + temp;
    }
    MessageBox.Show(msg );
    }

    Application.Run(new Form1());
    }
    }

    I modified the registry so when the user clicks the file, CE will send the file to the application to open:

    shell\open\command : "TB2007.exe %1" and shell\opendoc\command :"TB2007.exe -opendoc %1"

    In addition to making the registry entries, I had to copy the program to the Windows directory

    for the file associations to work correctly

    I then tested the program, here are the results:

    Test A: (proves we have instance count)

    1. Start program

    Message Box shows: 1

    Shut down program

    Test B: (proves instance count does not work)

    1. Start program

    Message Box shows: 1

    Go to windows Directory, start program again

    Application moves to foreground, no message box

    Test C: (proves we get file opendoc notifications )

    1. Click on a file:

    Message Box shows: 1 File '<filename>'

    Shut down the program

    Test D: (proves we do not get another file notification)

    1. Click on a file:

    Message Box shows: 1 File '<filename>'

    2. Click on another file - application moves to foreground, but does not give message box

    My conclusion is that two different instances will NOT work under CE for some reason.

    Question: Any idea why


  • file opened?