【小5聊】C# Winform窗体,程序点击运行第二次自动判断显示,解决不重复打开两个相同窗体

C# Winform窗体,程序运行后最小化到任务栏,当再次点击程序,能够自动将隐藏在任务栏的程序显示出来

默认情况下,如果不作处理,点击多次exe会运行多个窗体,具体看业务需求!

比如:QQ程序可以运行多个窗体,酷狗音乐运行一次后再次点击不会创建新窗体会直接显示

1、Main主方法代码

using mikeypet_common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyWinform
{
    static class Program
    {
        [DllImport("user32.dll")]
        private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
        private const int Value_HIDE = 0;              //常量,隐藏
        private const int Value_SHOWNORMAL = 1;        //常量,显示,标准状态
        private const int Value_SHOWMINIMIZED = 2;     //常量,显示,最小化
        private const int Valu

猜你喜欢

转载自blog.csdn.net/lmy_520/article/details/121142256
今日推荐