 |
|
 |
It saved me quite a bit of time. Thanks for the post!
|
|
|
|
 |
|
 |
My code looks like this:
.....
if(myAppIsNotRunningYet) { MyTray = new MyTray(); Application.Run(); }
else { }
..... public MyTray() { notifyIcon = new NotifyIcon(); .... notifyIcon.Visible = true; }
private void notifyIcon_DoubleClick(object sender, EventArgs e) { MainForm mainForm = new MainForm(); mainForm.ShowDialog(); }
|
|
|
|
 |
|
 |
You can do something like:
if(!SingleInstance.SingleApplication.Run()) { return; } else { MyTray = new MyTray(); Application.Run(); }
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
how can i restore a hidden form ? pls help me..
|
|
|
|
 |
|
 |
Can you elaborate your problem little bit more. Is it related my posted code or a general problem.
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
Thank you for reply. sorry for my poor English.
if i hide my form like
this.Hide();
how can i show my running applications main form when user double click the application again. i really need this ..
|
|
|
|
 |
|
 |
You can refer the code uploaded with this article.
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
i have this problem too, are there any solutions, i want create a listener, where the original instance start if a file or somethins is created....
|
|
|
|
 |
|
 |
Pls explain
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
Very simple and elegant solution, worked great for me the first time I tried it. And without any reference to any VB compatibility namespace! Really appreciate this a lot! - SC59
|
|
|
|
 |
|
 |
"GetCurrentInstanceWindowHandle()" does not work.Therefore "SwitchToCurrentInstance()" does not work.
|
|
|
|
 |
|
 |
You must be checking in debugger with VS2005 or VS2008. It is because of Hosting Process SingleInstance.vshost.exe created along with SingleInstance.exe. If you directly run the application without debugger you will see, application is working correctly.
Check following link to disable the Hosting Process- http://msdn.microsoft.com/en-us/library/ms185330(VS.80).aspx[^]
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
Thank you very much. Excuse me for my poor english. You are right, Hosting Process SingleInstance.vshost.exe created.But it does not work.
I add MessageBox as below: foreach(Process _process in processes) { MessageBox.Show(string.Format("ID={0}\nName:{1}\nHandle{2}",_process.Id,_process.MainModule.FileName,_process.MainWindowHandle)); if (_process.Id != process.Id && _process.MainModule.FileName == process.MainModule.FileName && _process.MainWindowHandle != IntPtr.Zero) { hWnd = _process.MainWindowHandle; break; } }
In no-debug mode,I find all of the first and second process's MainWindowHandle are 0.Why? My ide is VS2008.
|
|
|
|
 |
|
 |
I have tested with VS2005 working fine. Currently I don't have VS2008 setup with me .
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
Thanks again. Lead to the reasons for this phenomenon is a set of "ShowInTaskbar=false". This problem can be solved?
|
|
|
|
 |
|
 |
In this case MainWindowHandle will be NULL so the current code will not bring the already running process in focus but there will be only one instance.
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
Hi,
I have to open application when a file (.ext) is clicked (File is associated with that application like .doc with WINWORD).
Application should be single instance. When I click the .ext file it should open the application with that content. If an instance is runnig it should ask the user whether you want to close this application and then open the new .ext file.
Need help in C#.
Thanks Surya
|
|
|
|
 |
|
 |
When an extension is associated with an application and user click on a file with that extension, the file name is passed as a command line argument. You can look for the command line argument at launch time and process the request accordingly. But this need be done before SingleInstance.SingleApplication.Run(new FrmMain());
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
Hi Manish,
Thanks for the reply.
When I click on .ext file for the second time i.e already an instance is running. Now the clicked .ext file should be opened in the application.
Can you please tell me how to do it?
Thank You, Surya
|
|
|
|
 |
|
 |
For this you have implement some shared memory. Where you can write the shared argument (file name) and some way to notify the first process that something is there in shared memory to process.
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |
|
 |
this code very useful for me
Senthil.S Software Engineer
|
|
|
|
 |
|
 |
Thank You Sir.... This is what I need........
Sagar Pattnayak Software Developer Sun-Dew Solutions +91-9831169962
|
|
|
|
 |
|
 |
u my hero
noname
|
|
|
|
 |
|
 |
this code is working great but more than it demands, as it prevents another instances of the application even for another users can anyone help me to make it run application single instance for any number of users
|
|
|
|
 |
|
 |
For this you need to remove "Global\\" from line "mutex = new Mutex(true, "Global\\"+sExeName, out bCreatedNew);" of IsAlreadyRunning() in SingleInstance.cs in function while creating a mutex name.
Manish Agarwal manish.k.agarwal @ gmail DOT com
|
|
|
|
 |