PDA

View Full Version : سوال: باز نشدن برنامه بیش از یک بار !!!!



afshines
پنج شنبه 05 آبان 1390, 21:07 عصر
اگه کدی هست که با چک کردن task manager میتونه اجازه باز شدن برنامه رو نده لطفا بگین !!!:متفکر::متفکر::متفکر::متفکر :

ji ming u
پنج شنبه 05 آبان 1390, 21:09 عصر
توی پی دی اف 1000 نکته درمورد سی شارپ هست کدش را فراموش کردم

Sp|R|T
پنج شنبه 05 آبان 1390, 22:36 عصر
من هم همین مشکل رو دارم

میخوام مثلآ مثله یاهو باشه

که بیشتر از یک بار باز نشه

از چه رقم کدی استفاده کنیم ؟

pooria_googooli
جمعه 06 آبان 1390, 00:38 صبح
در پنجره solution explorer روی کلاس program دابل کلیک کن تا وارد محیط کد نویسیش بشی . بعد کد زیر را جایگزین کدی که برای main نوشته شده بذار .

// Optional
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
bool createdNew;
// To prevent the program to be started twice
///Create new mutex
System.Threading.Mutex appMutex = new System.Threading.Mutex(true, Application.ProductName, out createdNew);
///if creation of mutex is successful
if (createdNew)
{
Application.Run(new Login());
appMutex.ReleaseMutex();
}
else
{
/// if the app's already running
string msg = String.Format("The Program \"{0}\" is already running", Application.ProductName);
MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);

}