Home > Back-end >  Set maximum forms can be opened (the exe file can be opened 4 times only)
Set maximum forms can be opened (the exe file can be opened 4 times only)

Time:03-10

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.

  • Related