Hi,
I tried to use the following code to prevent duplicate execute of my program, i pub this in the form_load event procedure:
Process[] processes = Process.GetProcessesByName("C");
foreach (Process p in processes)
{
MessageBox.Show("Can't duplicate run this program,it is already running in the background.", "can't run again", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
but then now it kill itself; also i foudn that this relies on checking the filename that it runs at: I.E if it is C.exe, i need to put Process[] processes = Process.GetProcessesByName("C") to check is it runing, but if the user changes the filename it doesn't work then , how can i fix this or is there a better way to check duplicate execute ? many thanks for your help!