zoukankan
html css js c++ java
C#程序多用户只启动一个进程的方法
Main函数
[STAThread]
static
void
Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(
false
);
webscreenshot wb
=
new
webscreenshot();
Process current
=
Process.GetCurrentProcess();
bool
newinstance
=
true
;
Process[] processes
=
Process.GetProcessesByName(current.ProcessName);
//
遍历正在有相同名字运行的例程
foreach
(Process process
in
processes)
{
//
忽略现有的例程
if
(process.Id
!=
current.Id)
{
//
确保例程从EXE文件运行
if
(Assembly.GetExecutingAssembly().Location.Replace(
"
/
"
,
"
\\
"
)
==
current.MainModule.FileName)
{
//
返回另一个例程实例
current
=
process;
newinstance
=
false
;
break
;
}
}
}
if
(newinstance)
{
Application.Run(wb);
}
else
{
ShowWindowAsync(current.MainWindowHandle,
1
);
//
设置真实例程为foreground window
SetForegroundWindow(current.MainWindowHandle);
}
}
引入这两个API函数
[DllImport(
"
User32.dll
"
)]
private
static
extern
bool
ShowWindowAsync( IntPtr hWnd,
int
cmdShow);
[DllImport(
"
User32.dll
"
)]
private
static
extern
bool
SetForegroundWindow(IntPtr hWnd);
}
查看全文
相关阅读:
三十一:数据库之SQLAlchemy属性常用数据类型和Column常用参数
xml和configparser模块
shelve和hashlib模块
json和pickle序列化模块
sys模块和shutil模块
random和os模块
collections、time和datetime模块
Python模块及其导入
Python生成器和迭代器
Python装饰器
原文地址:https://www.cnblogs.com/xlfj521/p/883909.html
最新文章
利用canvas实现抽奖转盘---转载别人的
原生的强大DOM选择器querySelector
修改Tomcat使用的JVM内存大小
eclipse运行报java.lang.OutOfMemoryError: PermGen space解决方法
修改eclipse下tomcat的内存大小/解决内存溢出
springmvc上传文件
springmvc异常处理器
Eclipse取消或者关闭tomcat所有自动发布(部署)方法
springmvc整合mybatis详细教程
javax.naming.NameNotFoundException
热门文章
403 for URL: http://www.terracotta.org/kit/reflector
四十:数据库之SQLAlchemy实现排序的三种方式
三十九:数据库之SQLAlchemy.relationship方法中的cascade参数
三十八:数据库之ORM层面删除数据的注意事项
三十七:数据库之SQLAlchemy外建之多对多关系
三十六:数据库之SQLAlchemy外建之一对一关系
三十五:数据库之SQLAlchemy外建之一对多关系
三十四:数据库之SQLAlchemy外建及四种约束
三十三:数据库之SQLAlchemy.filter常用的过滤条件
三十二:数据库之SQLAlchemy.query函数可查询的数据和聚合函数
Copyright © 2011-2022 走看看