zoukankan      html  css  js  c++  java
  • 只启动一个应用程序实例控制类

    using System;
    using System.IO;
    using System.Diagnostics;
    using System.Threading;
    using System.Reflection;
    using System.Runtime.InteropServices;

    namespace Zhengzuo.CSharpCode
    {
        
    /// <summary>
        
    /// 只启动一个应用程序实例控制类
        
    /// </summary>

        public static class SingleInstance
        
    {
            
    private const int WS_SHOWNORMAL = 1;
            [DllImport(
    "User32.dll")]
            
    private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
            [DllImport(
    "User32.dll")]
            
    private static extern bool SetForegroundWindow(IntPtr hWnd);
            
    //标志文件名称
            private static string runFlagFullname = null;
            
    //声明同步基元
            private static Mutex mutex = null;

            
    /// <summary>
            
    /// static Constructor
            
    /// </summary>

            static SingleInstance()
            
    {
            }


            
    api实现


            
    Mutex实现


            
    设置标志实现
        }


    }
  • 相关阅读:
    python内建函数
    python中fromkeys的用法
    python中append和+号的区别
    python中input用法
    opencv3.2.0之绘图
    opencv3.2.0之Mat
    【学习】Python进行数据提取的方法总结【转载】
    【python】python中的enumerate()函数【笔记】
    【学习】如何安装GraphLab Create 【转载】
    【学习】python文件读写,用with open as的好处,非常好【转载】
  • 原文地址:https://www.cnblogs.com/dreign/p/946225.html
Copyright © 2011-2022 走看看