windows mobile 只能运行一个程序实例
static class Program
{
[System.Runtime.InteropServices.DllImport("coredll.Dll", SetLastError = true)]
private static extern int ReleaseMutex(IntPtr hMutex); [System.Runtime.InteropServices.DllImport("coredll.Dll", SetLastError = true)]
private static extern IntPtr CreateMutex(string lpMutexAttributes, bool bInitialOwner, string lpName);
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[MTAThread]
static void Main()
{
try
{
IntPtr hMutex = CreateMutex(null, false, "XXXXX");
if (System.Runtime.InteropServices.Marshal.GetLastWin32Error() != )
{
Application.Run(new FrmMain());
}
else
{
MessageBox.Show("程序已经运行.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
ReleaseMutex(hMutex);
}
}
catch (Exception)
{ MessageBox.Show("发生未知错误,程序退出!");
Application.Exit();
} }
}
windows mobile 只能运行一个程序实例的更多相关文章
- 如何让Windows程序只运行一个程序实例?
要实现VC++或者MFC只运行一个程序实例,一般采用互斥量来实现,即首先用互斥量封装一个只运行一个程序实例的函数接口: HANDLE hMutex = NULL; void MainDlg::RunS ...
- 同一个PC只能运行一个应用实例(考虑多个用户会话情况)
原文:同一个PC只能运行一个应用实例(考虑多个用户会话情况) class Program { private static Mutex m; [STAThread] static void Main( ...
- Winform程序只允许运行一个程序实例
/// <summary> /// 应用程序的主入口点. /// </summary> [STAThread] static void Main() { Application ...
- VC只运行一个程序实例
方法有很多,以下只是提供一种用的多的 一. 单文档程序 在程序App类的InitInstance中添加如下代码 BOOL CDDZApp::InitInstance() { /*只运行一个实例*/ / ...
- C# 只允许运行一个程序实例
using System; using System.Windows.Forms; using System.Runtime.InteropServices;//使用DllImport的必须. usi ...
- 进程的互斥运行:CreateMutex函数实现只运行一个程序实例
HANDLE hMutex=CreateMutex(NULL,TRUE,"HDZBUkeyDoctorTool"); if(hMutex) { if(ERROR_ALREADY_E ...
- 只能运行一个程序,禁止运行多个相同的程序 C#
原文发布时间为:2009-04-06 -- 来源于本人的百度文章 [由搬家工具导入] Program.cs 里面改成如下: static void Main() { ...
- wpf程序,只允许运行一个程序实例问题
https://bbs.csdn.net/topics/390486402 https://codereview.stackexchange.com/questions/20871/single-in ...
- Oracle 远程访问配置 在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标 C#反序列化XML异常:在 XML文档(0, 0)中有一个错误“缺少根元素” C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper Decimal类型截取保留N位小数向上取, Decimal类型截取保留N位小数并且不进行四舍五入操作
Oracle 远程访问配置 服务端配置 如果不想自己写,可以通过 Net Manager 来配置. 以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问. 1.网络监听配置 ...
随机推荐
- Android:不同drawable文件夹的区别
4.0后,新建android工程,会自动生成drawable,drawalbe-ldpi,drawable-mdpi,drawable-hdpi,drawable-xhdpi,drawable-xxh ...
- python‘s first day for me
计算机的基础 1,计算机由硬件及软件组成. 其中硬件主要包括了cpu,内存以及硬盘.软件则由操作系统以及一系列软件. 操作系统则可以操控硬件,使硬件完成一些需要的操作. python的历史 1989年 ...
- thymeleaf layout
摘自:https://tomoya92.github.io/2017/03/09/thymeleaf-layout/ thymeleaf的layout常用的有两种方式用法 第一种将页面里的每个 ...
- apache DOCUMENT_ROOT
问题描述:本地页面错误,+1上正常 本地及+1apache配置 <VirtualHost *:> ServerAdmin webmaster@dummy-host.example.com ...
- K老在拿图灵奖时的发言:Computer Programming as an Art
很多话说得很透彻,把一些觉比较精彩的摘抄一下. ... It seems to me that if the authors I studied were writing today, they wo ...
- Rhythmk 一步一步学 JAVA(4):Spring MVC -之拦截器
1.实现拦截器类(myInterceptor): package com.rhythmk.Interceptor; import javax.servlet.http.HttpServletReque ...
- firefox 插件 取消认证签名
Firebug Tab Mix plus :系统退出自动保存tab List. tab mix options>Session>start/exit>when browse ...
- Spring 学习记录4 ResourceLoader
ResourceLoader Spring的ApplicationContext继承了ResourceLoader接口.这个接口主要就是可以加载各种resource.. 接口还是比较简单的: /* * ...
- tomcat的中的Apache的apr是个啥东东???
这东西的作用说白了就是让我们的项目在其他系统中也可以正常运行!!!!
- Elasticsearch from+size 超过10000结果解决方法
方法一: 如果需要搜索分页,可以通过from size组合来进行.from表示从第几行开始,size表示查询多少条文档.from默认为0,size默认为10, 如果搜索size大于10000,需要设置 ...