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
文章首发
查看全文
相关阅读:
2020/10/10周总结
2020/10/02周总结
2020/9/28周总结
第十二周总结
第十一周总结
人月神话阅读笔记03
人月神话阅读笔记02
人月神话阅读笔记01
冲刺一8
冲刺一7
原文地址:https://www.cnblogs.com/skywind/p/470682.html
最新文章
需求征集系统06
需求征集系统进度05
需求征集系统进度04
周总结(八)
周总结(七)
周总结(六)
周总结(五)
周总结(四)
周总结(三)
周总结(二)
热门文章
周总结(一)
File文档用法总结(Python)
selenium用法总结
xx征集系统-(3)分类检索
xx征集系统
xx征集系统-(1)需求填报
2020/10/19周总结
代码大全-读后感(2)
【已解决】mysql excuteUpdate函数报错
代码大全--读后感(1)
Copyright © 2011-2022 走看看