Click here to Skip to main content
15,558,352 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regular Expression Pin
Kentamanos29-Jan-04 22:32
Kentamanos29-Jan-04 22:32 
GeneralRe: Regular Expression Pin
Heath Stewart30-Jan-04 5:03
protectorHeath Stewart30-Jan-04 5:03 
Generalprevent re-opening of application Pin
azusakt29-Jan-04 20:46
azusakt29-Jan-04 20:46 
GeneralRe: prevent re-opening of application Pin
Kentamanos29-Jan-04 21:03
Kentamanos29-Jan-04 21:03 
GeneralRe: prevent re-opening of application Pin
Mazdak30-Jan-04 2:57
Mazdak30-Jan-04 2:57 
GeneralRe: prevent re-opening of application Pin
Heath Stewart30-Jan-04 5:00
protectorHeath Stewart30-Jan-04 5:00 
GeneralRe: prevent re-opening of application Pin
azusakt30-Jan-04 15:18
azusakt30-Jan-04 15:18 
GeneralRe: prevent re-opening of application Pin
Heath Stewart30-Jan-04 15:39
protectorHeath Stewart30-Jan-04 15:39 
Kentamanos already did above. You acquire a Mutex with the first instance and the second instance (or more) can't acquire it so you exit the application:
string mutexName = "some unique string";
bool acquired;
new Mutex(true, mutexName, out acquired);
if (acquired)
{
  // Run your main form as the application window.
  Application.Run(new MainForm());
}
else
{
  Application.Exit();
}
Optionally, if you don't acquire the Mutex, you can grab the command line parameters (like a filename) and force the existing process to open a new document (or set focus to the existing document). There are plenty of examples of this here on CodeProject and on the 'net.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: prevent re-opening of application Pin
Bo Hunter30-Jan-04 15:43
Bo Hunter30-Jan-04 15:43 
GeneralC# Pin
BP12829-Jan-04 19:17
BP12829-Jan-04 19:17 
GeneralRe: C# Pin
Kentamanos29-Jan-04 20:00
Kentamanos29-Jan-04 20:00 
GeneralDirectX Tutorial Pin
Shree29-Jan-04 18:35
Shree29-Jan-04 18:35 
GeneralRe: DirectX Tutorial Pin
Mazdak29-Jan-04 20:07
Mazdak29-Jan-04 20:07 
GeneralMissing file Pin
BP12829-Jan-04 17:43
BP12829-Jan-04 17:43 
GeneralRe: Missing file Pin
Kentamanos29-Jan-04 17:51
Kentamanos29-Jan-04 17:51 
GeneralRe: Missing file Pin
BP12829-Jan-04 17:53
BP12829-Jan-04 17:53 
GeneralRe: Missing file Pin
Heath Stewart30-Jan-04 4:37
protectorHeath Stewart30-Jan-04 4:37 
GeneralAutomatic WSDL generation Pin
Kentamanos29-Jan-04 16:48
Kentamanos29-Jan-04 16:48 
GeneralRe: Automatic WSDL generation Pin
Kentamanos29-Jan-04 17:09
Kentamanos29-Jan-04 17:09 
GeneralRe: Automatic WSDL generation Pin
Kentamanos29-Jan-04 17:32
Kentamanos29-Jan-04 17:32 
GeneralRe: Automatic WSDL generation Pin
Heath Stewart30-Jan-04 4:54
protectorHeath Stewart30-Jan-04 4:54 
GeneralRe: Automatic WSDL generation Pin
Kentamanos30-Jan-04 7:27
Kentamanos30-Jan-04 7:27 
GeneralCOM+ Catalog Infomation Pin
kimsangwoo29-Jan-04 15:39
kimsangwoo29-Jan-04 15:39 
GeneralRe: COM+ Catalog Infomation Pin
Heath Stewart30-Jan-04 4:45
protectorHeath Stewart30-Jan-04 4:45 
GeneralRe: COM+ Catalog Infomation Pin
kimsangwoo30-Jan-04 13:42
kimsangwoo30-Jan-04 13:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.