I have added a context menu item to my application. The problem is that, if it is already running and I right click a file, another instance of the program opens up. How can I check if the program is already running, and if it is, how can I pass control to the existing instance
Thanks in advance.

Checking if application is already running
chenwen
public static bool IsAppAlreadyRunning()
{
Process currentProcess = Process.GetCurrentProcess();
return Process.GetProcessesByName(currentProcess.Name).Length > 0;
}
you just have to modify it to suit your need.
HTH,
zeusmt
You can use Remoting or any of the IPC mechanisms listed here: http://msdn.microsoft.com/library/en-us/ipc/base/interprocess_communications.asp
Take a look at some of these articles, this should covers a lot:
Malleyo
hi,
//if it is already running and I right click a file, another instance of the program opens up
do you have particular extension associated with your application
unfortunately the only articale that i have about that in vb not C# here its the link
http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell_Projects/Registering_File_Associations/article.asp
hope this helps
skeptic08
caius
BTW - Genghis is completely free and includes full source code.
Adamx
I got the part about checking if it's already running, but how about passing control to that instance The program keeps a list of files and when I right-click a file and choose Shred it should be added to that list. Or, if this is way too hard to achieve, at least I should make it so, that if I select, say, 2 files and choose shred, I don't get two apps, each with one file in the list.
Thanks for the link, but my knowledge of VB is null.
Thrill5
Take a look at the following article: A simple C# function to add context menu items in Explorer.
ghomf
Please lett us know whis technique you've picked and if you get everything working correctly.
craig_munday28
hi,
i need this tutorial plz if you don't mind
thx
Antoine64