⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program.cs

📁 人事管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace BlueHill_Win_
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            
            string procName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;

            if ((System.Diagnostics.Process.GetProcessesByName(procName)).GetUpperBound(0) > 0)
            {
                
                MessageBox.Show("该应用系统已经在运行...", "系统警告", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
               
            }
            else
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Login());   

            //Process instance = RunningInstance();
            //if (instance == null)
            //{
            //    System.Windows.Forms.Application.EnableVisualStyles();    //这两行可以让窗体具有XP风格.
            //    System.Windows.Forms.Application.DoEvents();
            //    Application.Run(new Login());
            //}
            //else
            //{
            //    HandleRunningInstance(instance);
            //}
        }

        //#region   只运行一个实例
        //public static Process RunningInstance()
        //{
        //    Process current = Process.GetCurrentProcess();
        //    Process[] processes = Process.GetProcessesByName(current.ProcessName);
        //    //遍历与当前进程名称相同的进程列表 
        //    foreach (Process process in processes)
        //    {
        //        //Ignore the current process 
        //        if (process.Id != current.Id)
        //        {
        //            //Make sure that the process is running from the exe file. 
        //            if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
        //            {
        //                //Return the other process instance. 
        //                return process;
        //            }
        //        }
        //    }
        //    return null;
        //}
        //private static void HandleRunningInstance(Process instance)
        //{
        //    MessageBox.Show("该应用系统已经在运行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //    ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL); //调用api函数,正常显示窗口 
        //    SetForegroundWindow(instance.MainWindowHandle); //将窗口放置最前端。 
        //}
        //[DllImport("User32.dll")]
        //private static extern bool ShowWindowAsync(System.IntPtr hWnd, int cmdShow);
        //[DllImport("User32.dll")]
        //private static extern bool SetForegroundWindow(System.IntPtr hWnd);
        //private const int WS_SHOWNORMAL = 1;
        //#endregion 
    }
    public class Win32
    {
        public const Int32 AW_HOR_POSITIVE = 0x00000001;    // 从左到右打开窗口
        public const Int32 AW_HOR_NEGATIVE = 0x00000002;    // 从右到左打开窗口
        public const Int32 AW_VER_POSITIVE = 0x00000004;    // 从上到下打开窗口
        public const Int32 AW_VER_NEGATIVE = 0x00000008;    // 从下到上打开窗口
        public const Int32 AW_CENTER = 0x00000010;
        public const Int32 AW_HIDE = 0x00010000;        // 在窗体卸载时若想使用本函数就得加上此常量
        public const Int32 AW_ACTIVATE = 0x00020000;    //在窗体通过本函数打开后,默认情况下会失去焦点,除非加上本常量
        public const Int32 AW_SLIDE = 0x00040000;
        public const Int32 AW_BLEND = 0x00080000;       // 淡入淡出效果
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern bool AnimateWindow(
        IntPtr hwnd,  //  handle  to  window    
        int dwTime,  //  duration  of  animation    
        int dwFlags  //  animation  type    
        );
    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -