How can I set Maximum forms (exe file) can be opened
(I want to set the exe file can be opened 4 times Only!)
MessageBox("You have already opened This exe file 4 times";
CodePudding user response:
you can use this one:
Dim instanceCount As Integer = Process.GetProcessesByName("yourexename").Count()
If instanceCount > 4 then
MessageBox("You have already opened This exe file 4 times")
Environment.Exit(0)
End If
CodePudding user response:
You can check the running processes in C# by calling Process.GetProcessesByName("YourApplicationName")
and check if there are greater than 4 processes running. If there are, show your MessageBox and then quit the current instance of the application.