I want my program to be single-instance. So my goal is to detect if the program (installed in the x86 Program Files folder) is already running and inform of the fact with a message the PC user.
The code :
Works fine, BUT THERE IS A PROBLEM.
In effect I want that EVERY USER OF THE SAME PC can run the program only once... but with the above code if a PC user runs the program without to close it and then another PC User logs the PC... if he runs the program is displayed the above message: he can't run the program if the program itself is opened from another PC user.
How to make the program at single istance for every user of the same PC?
Ty :)
The code :
Code:
If Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1 Then
MessageBox.Show("The program is already running!!", " Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
End IfIn effect I want that EVERY USER OF THE SAME PC can run the program only once... but with the above code if a PC user runs the program without to close it and then another PC User logs the PC... if he runs the program is displayed the above message: he can't run the program if the program itself is opened from another PC user.
How to make the program at single istance for every user of the same PC?
Ty :)