zoukankan      html  css  js  c++  java
  • windows mobile 只能运行一个程序实例

     1 static class Program
     2     {
     3         [System.Runtime.InteropServices.DllImport("coredll.Dll", SetLastError = true)]
     4         private static extern int ReleaseMutex(IntPtr hMutex);
     5 
     6         [System.Runtime.InteropServices.DllImport("coredll.Dll", SetLastError = true)]
     7         private static extern IntPtr CreateMutex(string lpMutexAttributes, bool bInitialOwner, string lpName);
     8         /// <summary>
     9         /// 应用程序的主入口点。
    10         /// </summary>
    11         [MTAThread]
    12         static void Main()
    13         {
    14             try
    15             {
    16                 IntPtr hMutex = CreateMutex(null, false, "XXXXX");
    17                 if (System.Runtime.InteropServices.Marshal.GetLastWin32Error() != 0183)
    18                 {
    19                     Application.Run(new FrmMain());
    20                 }
    21                 else
    22                 {
    23                     MessageBox.Show("程序已经运行.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
    24                     ReleaseMutex(hMutex);
    25                 }
    26             }
    27             catch (Exception)
    28             {
    29 
    30                 MessageBox.Show("发生未知错误,程序退出!");
    31                 Application.Exit();
    32             }
    33 
    34         }
    35     }
  • 相关阅读:
    1010考试T1
    P5631 最小mex生成树 分治 并查集
    P4366 [Code+#4]最短路 建图 最短路
    P1654 OSU! 期望概率DP
    7.26集训
    7.25集训
    7.23集训
    7.22集训
    7.21test
    7.12test
  • 原文地址:https://www.cnblogs.com/litian/p/5112955.html
Copyright © 2011-2022 走看看