Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi all,

I have a program in C# that runs from startup.... What I want to do is...

1. Make it single Instance Application...
2. When The user will double click some specific files from desktop, The file name should be passed to the running instance of my application as Command Line arguments(Now it opens in separate instances)

Please help me :(
Posted
Comments
[no name] 30-Jun-13 10:27am    
You should be improving the question that you already have instead of reposting your question.
Madhav Hatwalne 30-Jun-13 11:45am    
Do some search instead of just posting questions!!!

There are 2 parts of this question, which are solved separately. To answer the second part first, you need to be able to set up some sort of inter-process communication in your app so that it will accept requests from another program when it is already running. I suggest use of a pipe (or shared memory or network connection or dde). It is probably easiest to develop/implement if you have a 'dummy' second app that sends data over the connection and is executed by your running app. Get this running first.

The second part is actually your first question. Google will give you numerous mechanisms for single instance apps. In the startup code for your app, if it detects that it is the second (or subsequent) instance running, collect the command line info and relay that to the first instance using the code you developed above.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 30-Jun-13 20:56pm    
My 5, but please see also my answer where I provided more concrete and complete advice on the techniques to be used.
—SA
In my past answers, I provided a comprehensive description of the approach solving this and related problem. Please see:
Enter multiple commands to only one process instance[^],
Custom Windows right-click command launching multiple instances[^].

—SA
 
Share this answer
 
Comments
H.Brydon 1-Jul-13 0:30am    
My 5 back - you do it well, SA.
Sergey Alexandrovich Kryukov 1-Jul-13 0:38am    
Thank you, Harvey.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900