zoukankan      html  css  js  c++  java
  • 让程序只能运行一次

    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.IO;

    namespace frameTest
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                string MName = Process.GetCurrentProcess().MainModule.ModuleName;
                string PName = Path.GetFileNameWithoutExtension(MName);
                Process[] myProccess = Process.GetProcessesByName(PName);
                if (myProccess.Length > 1)
                {
                    MessageBox.Show("程序已经运行,不能重复打开", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
                else
                {


                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form1());
                }
            }
        }
    }

  • 相关阅读:
    视频直播思路
    Swift 算法实战之路:栈和队列
    多线程(RunLoop)
    Charle抓包与wireshark使用
    CoreData归纳使用
    支付宝接入心得(流程)
    TableView的性能优化
    app启动页问题
    公司的开发者账号申请
    java关于时间的笔记
  • 原文地址:https://www.cnblogs.com/armanda/p/3345860.html
Copyright © 2011-2022 走看看