I read this on codeproject and wanted to save it incase I need it down the road
To check that the program is the first instance, try this code :-
You could also pass the necessary parameter via a file. For instance write an file somewhere, containing the necessary parameters and use a
Depands how slick you want it, but the simplest options are usually the best.
'Check to see if already running
Dim currentProcess As Process = Process.GetCurrentProcess()
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)
If allProcesses.Length > 1 Then
'already running
Else
'not already running
End If
You could also pass the necessary parameter via a file. For instance write an file somewhere, containing the necessary parameters and use a
FileSystemWatcher
to monitor the file for changes.Depands how slick you want it, but the simplest options are usually the best.
No comments:
Post a Comment