You can store one value in registry when the exe gets run first time
Now second time check if that value exist in the registry exe don't get run or immediately gets closed.
Or you can also create one file in any location invisible to the user
and second time check if that file exist exe don't get run
if still have prob
contact me at [email]snipped email[/email]
First of all i dont think .net provides such behaviour by default.
There are different ways for doing this, have a look at some of the suggestion below:
1. Create a registry entry and on each launch check the value for it. e.g. Check to 1 or True on first launch and exit it on the following launches.
2. Make a file and serailize a object in that file. e.g. serialize boolean value true for the first launch and by checking it never re-launch the exe.
PS. The above mentioned checks could be performed in the main function of your application i.e. prior to launch of the application
I'm a fairly junior C# programmer, so I don't know that this is the best approach ... I've used the following code to ensure that only one instance of the program is running. The approach is to set a Mutex with a unique name whenever the program runs. I check for this Mutex on startup and assume that I'm the only one running if I don't find it.
private Mutex mutex;
private string mutexName = "MyProgramMutexToEnsureThatOnlyASingleInstanceIsRunning";
// code to ensure that only one copy of the software is running.
mutex = Mutex.OpenExisting ( mutexName );
//since it hasn’t thrown an exception, then we already have one copy of the app open.
MessageBox.Show ( "A copy of the software is already open. Please check your system tray (notification area).",
"My Software", MessageBoxButtons.OK, MessageBoxIcon.Information );
Environment.Exit ( 0 );
//since we didn’t find a mutex with that name, create one
mutex = new Mutex ( true, mutexName );
**how to solve invalid keystore error in android studio here is error report----------------------->
here is error report--------> error:Error:java.lang.RuntimeException: com.android.ide.common.signing.KeytoolException: Failed to read key palash from store "D:\MyApplication3.idea\workspace.xml": Invalid keystore format ...