one instance of the program?

  • Thread starter Thread starter Dzemo
  • Start date Start date
D

Dzemo

how to ensure that my program can't start twice on the computer and tell
user something like "Program already started"
Can I do anything with Process Class
thx
 
You can use Process.GetProcessesByName(processName) to guess if there is
another instance running.

You can get the process name with
Syetm.Reflection.Assembly.GetExecutingAssembly.GetName.Name.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Carlos,

Carlos J. Quintero said:
You can use Process.GetProcessesByName(processName) to guess if there is
another instance running.

You can get the process name with
Syetm.Reflection.Assembly.GetExecutingAssembly.GetName.Name.

This basically works, but note that the process name is not necessarily
unique.
 
Hi Cor,

Just curious, if the app crashes with an unhandled exception, is the mutex
released? Isn´t an exception handler needed?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Carlos,

I don't know however I could run this program as often as I did like.

\\\
Public Class myw
Public Shared Sub main()
MessageBox.Show("I am new alive")
Dim owned As Boolean
Dim mut As New System.Threading.Mutex _
(True, "xvcjsdf67AS124#$3", owned)
End
End Sub
End Class
////

I don't know a better method to kill a program

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top