惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
量子位
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
B
Blog RSS Feed
宝玉的分享
宝玉的分享
Security Latest
Security Latest
小众软件
小众软件
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
博客园_首页
美团技术团队
T
Tailwind CSS Blog
The Cloudflare Blog
爱范儿
爱范儿
L
LINUX DO - 热门话题
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
V
Vulnerabilities – Threatpost
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
阮一峰的网络日志
阮一峰的网络日志
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Schneier on Security
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
Schneier on Security
Schneier on Security
Jina AI
Jina AI
N
News and Events Feed by Topic
C
Cisco Blogs
L
Lohrmann on Cybersecurity
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cisco Talos Blog
Cisco Talos Blog
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
O
OpenAI News
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 撬棍

【.Net】2、8、16进制转换 【.Net】执行CMD命令 【.Net】获取随机数函数 【.Net】注册程序开机启动 【.Net】把窗体“钉”到桌面上 【.Net】多语言查看MSDN 【.Net】 显示星期字符串 【.Net】 判断时间字符串正确性 【.Net】 实现窗口拖动 [C++]函数返回值 [C++]数组参数 [C++]const的指针使用 [C++]指针类型出参 [VBA]Excel输出utf-8编码格式文件 使用WideCharToMultiByte 【C++】split [C语言学习]之打印万年历 - 撬棍 - 博客园 [VB6.0]让程序在任务列表和资源管理器“隐身” [InstallShield]FindAllFiles与SetFileInfo配合实现文件加多文件属性设置 [VB]修改注册表让程序开机自动运行 - 撬棍 - 博客园
【.Net】 Winform 单例运行实例
撬棍 · 2013-09-17 · via 博客园 - 撬棍

VB:

    简单了,只要在Project的属性里设置"( Make Single Instance Application)生成单个应用实例程序"即可。

    VB这样设置之后,再次启动应用程序,正在运行的应用程序被激活。不会弹出消息。

C#:

    通过代码实现,修改Program.cs文件

static class Program  
  {  
    private static Mutex m_Mutex;  

    [STAThread]  
    static void Main()  
    {  
        Application.EnableVisualStyles();  
        Application.SetCompatibleTextRenderingDefault(false);  
 
        bool isRunning;  
        m_Mutex = new Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out isRunning);  
        if (isRunning)  
            Application.Run(new Form1());  
        else 
            MessageBox.Show("The application is already running.", Application.ProductName,  MessageBoxButtons.OK, MessageBoxIcon.Exclamation);  
    }  
}