zoukankan
html css js c++ java
一个程序只能启动一次实现
原文网址:
http://free56.cn/post/3.html
using
System;
using
System.Runtime.InteropServices;
namespace
JKLib
{
/**/
///
<summary>
///
一个程序只能启动一次实现
///
</summary>
public
class
SingleInstance
{
[DllImport(
"
user32.dll
"
)]
private
static
extern
IntPtr FindWindow(
string
lpClassName,
string
lpWindowName);
[DllImport(
"
user32.dll
"
)]
private
static
extern
bool
SetForegroundWindow(IntPtr hWnd);
[DllImport(
"
user32.dll
"
)]
private
static
extern
bool
ShowWindowAsync(IntPtr hWnd,
int
nCmdShow);
[DllImport(
"
user32.dll
"
)]
private
static
extern
bool
IsIconic(IntPtr hWnd);
/**/
///
<summary>
///
显示窗体命令值
///
</summary>
private
const
int
SW_RESTORE
=
9
;
/**/
///
<summary>
///
窗体名称
///
</summary>
private
string
WinTitle;
/**/
///
<summary>
///
一个程序只能启动一次实现
///
</summary>
///
<param name="_WinTitle">
程序名
</param>
public
SingleInstance(
string
_WinTitle)
{
WinTitle
=
_WinTitle;
}
private
IntPtr hWnd
=
(System.IntPtr)
null
;
/**/
///
<summary>
///
是否只有一个窗口
///
</summary>
public
bool
IsSingleInstance
{
get
{
hWnd
=
FindWindow(
null
,WinTitle);
return
hWnd
==
(System.IntPtr)
null
;
}
}
/**/
///
<summary>
///
使当前程序进程处于活动状态
///
</summary>
public
void
RaiseOtherProcess()
{
if
(hWnd
==
(System.IntPtr)
null
)
return
;
else
{
if
(IsIconic(hWnd))
{
ShowWindowAsync(hWnd,SW_RESTORE);
}
SetForegroundWindow(hWnd);
return
;
}
}
}
}
原文网址:
http://free56.cn/post/3.html
文章首发
查看全文
相关阅读:
cas 单点登录服务端客户端配置
POI 导出excel
关于小米手机刷机亲尝
C#对本地文件重命名--适用于下载的图片、电视剧等奇怪名字的重命名
泛型List<T>与非泛型ArrayList
设置一键启动多文件
网页显示电子表
插入sql语句01值时,在数据库中的查询时显示为1
C#面向对象--继承
SqlServer数据库查询不同字段-年龄段分析
原文地址:https://www.cnblogs.com/skywind/p/470682.html
最新文章
ora-16038 ora-19504 ora-00312 oracle-16014
互联网背景时代下的大机遇,为什么用nosql
NoSQL入门概述
常见的块状元素与内联元素
HTML中行内元素与块级元素有哪些及区别
顶级、块级、内联,html元素的三大分类
block,inline和inline-block概念和区别
Java解析Json字符串--复杂对象
vvvv
Tomcat部署Web应用方法总结
热门文章
Maven 集成Tomcat插件
解决安卓微信浏览器中上传不能调用相机的问题
XML签名Cannot resolve element with ID XXXX 解决方案
Mac(Linux)上安装memcached步骤
(转)MySQL建表设置两个默认CURRENT_TIMESTAMP的技巧
MySQL建表时列名同保留字重复问题解决办法
MySQL下创建序列及创建自定义函数方法介绍
Spring整合Struts的两种方式介绍
ognl.NoSuchPropertyException(没有对应属性异常)
使用Struts,前台提交给后台的汉字为乱码
Copyright © 2011-2022 走看看