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     }
  • 相关阅读:
    kubuntu设置
    odoo git环境搭建
    ubuntu Gnome 14.10添加打印机
    ubuntu 14.10安装Balsamiq Mockups
    elementary os luna安装配置
    OpenERP QWeb模板标签笔记
    pycharm3 注册码
    统计项目代码
    odoo filter 日期
    opencart 安装
  • 原文地址:https://www.cnblogs.com/litian/p/5112955.html
Copyright © 2011-2022 走看看