Click here to Skip to main content
15,867,594 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regular Expression Pin
Kentamanos29-Jan-04 21:32
Kentamanos29-Jan-04 21:32 
GeneralRe: Regular Expression Pin
Heath Stewart30-Jan-04 4:03
protectorHeath Stewart30-Jan-04 4:03 
Generalprevent re-opening of application Pin
azusakt29-Jan-04 19:46
azusakt29-Jan-04 19:46 
GeneralRe: prevent re-opening of application Pin
Kentamanos29-Jan-04 20:03
Kentamanos29-Jan-04 20:03 
GeneralRe: prevent re-opening of application Pin
Mazdak30-Jan-04 1:57
Mazdak30-Jan-04 1:57 
GeneralRe: prevent re-opening of application Pin
Heath Stewart30-Jan-04 4:00
protectorHeath Stewart30-Jan-04 4:00 
GeneralRe: prevent re-opening of application Pin
azusakt30-Jan-04 14:18
azusakt30-Jan-04 14:18 
GeneralRe: prevent re-opening of application Pin
Heath Stewart30-Jan-04 14:39
protectorHeath Stewart30-Jan-04 14: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 14:43
Bo Hunter30-Jan-04 14:43 
GeneralC# Pin
BP12829-Jan-04 18:17
BP12829-Jan-04 18:17 
GeneralRe: C# Pin
Kentamanos29-Jan-04 19:00
Kentamanos29-Jan-04 19:00 
GeneralDirectX Tutorial Pin
Shree29-Jan-04 17:35
Shree29-Jan-04 17:35 
GeneralRe: DirectX Tutorial Pin
Mazdak29-Jan-04 19:07
Mazdak29-Jan-04 19:07 
GeneralMissing file Pin
BP12829-Jan-04 16:43
BP12829-Jan-04 16:43 
GeneralRe: Missing file Pin
Kentamanos29-Jan-04 16:51
Kentamanos29-Jan-04 16:51 
GeneralRe: Missing file Pin
BP12829-Jan-04 16:53
BP12829-Jan-04 16:53 
GeneralRe: Missing file Pin
Heath Stewart30-Jan-04 3:37
protectorHeath Stewart30-Jan-04 3:37 
GeneralAutomatic WSDL generation Pin
Kentamanos29-Jan-04 15:48
Kentamanos29-Jan-04 15:48 
GeneralRe: Automatic WSDL generation Pin
Kentamanos29-Jan-04 16:09
Kentamanos29-Jan-04 16:09 
GeneralRe: Automatic WSDL generation Pin
Kentamanos29-Jan-04 16:32
Kentamanos29-Jan-04 16:32 
GeneralRe: Automatic WSDL generation Pin
Heath Stewart30-Jan-04 3:54
protectorHeath Stewart30-Jan-04 3:54 
GeneralRe: Automatic WSDL generation Pin
Kentamanos30-Jan-04 6:27
Kentamanos30-Jan-04 6:27 
GeneralCOM+ Catalog Infomation Pin
kimsangwoo29-Jan-04 14:39
kimsangwoo29-Jan-04 14:39 
GeneralRe: COM+ Catalog Infomation Pin
Heath Stewart30-Jan-04 3:45
protectorHeath Stewart30-Jan-04 3:45 
GeneralRe: COM+ Catalog Infomation Pin
kimsangwoo30-Jan-04 12:42
kimsangwoo30-Jan-04 12: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.