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实现


            
    设置标志实现
        }


    }
  • 相关阅读:
    Element-UI中Upload上传文件前端缓存处理
    Puppeteer前端自动化测试实践
    javascript-高级用法
    什么是闭包?闭包的优缺点?
    浅谈网站性能之前端性能优化
    2019前端面试题汇总(主要为Vue)
    从官网学习Node.js FS模块方法速查
    这才是官方的tapable中文文档
    面试官问:JS的this指向
    开启梦幻般的webrtc之旅
  • 原文地址:https://www.cnblogs.com/dreign/p/946225.html
Copyright © 2011-2022 走看看