File Associations - Multiple Instances

G

Guest

Hi

I have a CF.Net small application which is set up with a file association. I
click on a file of a certain type and my program loads fine and the filename
is passed as an argument.

If I click on another file the previous window redisplays and the new file
is not loaded. This is the CF.Net single instance restriction at work.

Is there an accepted way to be able to pass or retrieve the new arguments in
the old instance of the application? I've looked for documentation on this
but I haven't found any.

The ways of "hacking" multiple instances seem to have changed in CE 5.0
since the window class is now #NETCF_AGL_PARK_+pathtoapp and the window title
blank. The old trick of changing the window title doesn't work. If that did
work I'd use a named event + WM_COPYDATA but it seems that route is closed. I
don't really want to have two *.exe's.

Thanks in advance for any suggestions.
 
G

Guest

Since the CF enforces singleton behavior before you get an opportunity to
intervene, you have to hack around it. The typical way I go is to hack the
window name to prevent multiple instances and use IPC to send the new path
to the existing instance as you suggest. Yes, it changed how it works in CF
2, but the principal remains the same. You can use the Environment class to
determine which you're running under when you launch.
 
G

Guest

Chris

This worked for me before but now it seems that the window class name
contains the filename and path of the started CF app not the window name so
changing the window name does not allow a second instance.

I think I'm going to have to have two applications. One which checks for the
instance of the second and passes its args to it if it exists and starts the
second if it doesn't exist.

I wish there was a "normal" way of doing this. Actually it would be good if
the CF sent a message to the running instance of an application with the
called arguments when it terminates the second instance.

This does not violate the "one running instance" principle and it's a very
common thing to want to do (at least for me it is).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top