zoukankan      html  css  js  c++  java
  • WINCE.NET中程序只运行一次

     1 using System;
     2 using System.Runtime.InteropServices;
     3 
     4 class Mutex
     5 {
     6     [DllImport("coredll.Dll")]
     7     private static extern int GetLastError();
     8 
     9     [DllImport("coredll.Dll")]
    10     private static extern int ReleaseMutex(IntPtr hMutex);
    11 
    12     [DllImport("coredll.Dll")]
    13     private static extern IntPtr CreateMutex(
    14         SECURITY_ATTRIBUTES lpMutexAttributes,
    15         bool bInitialOwner, string lpName);
    16 
    17     [StructLayout(LayoutKind.Sequential)]
    18     public class SECURITY_ATTRIBUTES
    19     {
    20         public int nLength;
    21         public int lpSecurityDescriptor;
    22         public int bInheritHandle;
    23     }
    24 
    25     private const int ERROR_ALREADY_EXISTS = 0183;
    26 
    27     public static void Run()
    28     {
    29         IntPtr hMutex = CreateMutex(nullfalse"ZJS_FJ");
    30         if (GetLastError() != ERROR_ALREADY_EXISTS)
    31         {
    32             System.Windows.Forms.Application.Run(new Form1());
    33             return;
    34         }
    35         else
    36         {
    37             ReleaseMutex(hMutex);
    38             return;
    39         }
    40     }
    41 // class
    42 
  • 相关阅读:
    【luogu P4139】 上帝与集合的正确用法
    pb_ds学习
    【luogu P3868】 [TJOI2009]猜数字
    BZOJ3040: 最短路(road)
    【luogu P1064】 金明的预算方案
    【luogu P2893】 [USACO08FEB]修路Making the Grade
    【luogu P2801】 教主的魔法
    UVA10816 Travel in Desert
    P2916 [USACO08NOV]安慰奶牛Cheering up the Cow
    【BZOJ 2054】 疯狂的馒头
  • 原文地址:https://www.cnblogs.com/answer/p/808418.html
Copyright © 2011-2022 走看看