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基础
    用纯css改变下拉列表select框的默认样式兼容ie9需要用js
    如何阻止360浏览器backspace键的默认快捷键
    js判断undefined类型,undefined,null, 的区别详细解析
    jquery事件日历插件e-calendar 的修改
    each和for一起使用
    2019.9.24 网络ip小知识
    数据库SQL开始学习_5
    2019.9.22 java小知识
    数据库SQL开始学习_4
  • 原文地址:https://www.cnblogs.com/dreign/p/946225.html
Copyright © 2011-2022 走看看