By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

How to Send File to Running Application

P: n/a
I have an app that allows only one instance to run at a time. I have a file
extension associated with this app and would like to pass a running instance
the file name if a user double-clicks the file directly.

Any help would be greatly appreciated.

PJ
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
PJ,

It's a little complicated, but it is possible. First, you would need to
create a remoting server in your application, such that the application that
is the only one running would be the one that is the server. This would
have a method which would take a filename to process.

Then, in the code for the beginning of your app, if you determine that
your app is to be shut down (because another instance is running), you would
hook up to the remoting server that the other app is hosting, and make the
call, passing the filename to process (it should be part of the command line
parameters).

If you are using .NET 2.0, all of this is done for you. There is an
question in the current issue of MSDN magazine in the ".NET Matters"
section. The question regards single-instance applications, and the answer
shows how all of this is done for you. You can find it at (watch for line
wrap):

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"PJ Olson" <pe*****@sux.com> wrote in message
news:eI****************@TK2MSFTNGP10.phx.gbl...
I have an app that allows only one instance to run at a time. I have a file
extension associated with this app and would like to pass a running
instance the file name if a user double-clicks the file directly.

Any help would be greatly appreciated.

PJ

Nov 17 '05 #2

P: n/a
That is very helpful!

Thanks,
PJ

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:u$**************@tk2msftngp13.phx.gbl...
PJ,

It's a little complicated, but it is possible. First, you would need
to create a remoting server in your application, such that the application
that is the only one running would be the one that is the server. This
would have a method which would take a filename to process.

Then, in the code for the beginning of your app, if you determine that
your app is to be shut down (because another instance is running), you
would hook up to the remoting server that the other app is hosting, and
make the call, passing the filename to process (it should be part of the
command line parameters).

If you are using .NET 2.0, all of this is done for you. There is an
question in the current issue of MSDN magazine in the ".NET Matters"
section. The question regards single-instance applications, and the
answer shows how all of this is done for you. You can find it at (watch
for line wrap):

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"PJ Olson" <pe*****@sux.com> wrote in message
news:eI****************@TK2MSFTNGP10.phx.gbl...
I have an app that allows only one instance to run at a time. I have a
file extension associated with this app and would like to pass a running
instance the file name if a user double-clicks the file directly.

Any help would be greatly appreciated.

PJ


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.