限制程序多次运行方法II
2007-04-09 09:05
148 查看
(1)在全局的外部函数中写:
Function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library 'kernel32.dll'
Function ulong GetLastError () library 'kernel32.dll'
(2)在应用的Open事件中写如下代码
ulong ll_mutex, ll_err
string ls_mutex_name
if handle (GetApplication (), false) <> 0 then
ls_mutex_name = this.AppName + char (0)
ll_mutex = CreateMutexA (0, 0, ls_mutex_name)
ll_err = GetLastError ()
if ll_err = 183 then
// 程序已经运行
MessageBox ('提示信息', '程序已经运行了!')
Halt close
else
// 程序未运行
open(w_main)
end if
else//开发模式
open(w_main)
end if
Function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library 'kernel32.dll'
Function ulong GetLastError () library 'kernel32.dll'
(2)在应用的Open事件中写如下代码
ulong ll_mutex, ll_err
string ls_mutex_name
if handle (GetApplication (), false) <> 0 then
ls_mutex_name = this.AppName + char (0)
ll_mutex = CreateMutexA (0, 0, ls_mutex_name)
ll_err = GetLastError ()
if ll_err = 183 then
// 程序已经运行
MessageBox ('提示信息', '程序已经运行了!')
Halt close
else
// 程序未运行
open(w_main)
end if
else//开发模式
open(w_main)
end if
相关文章推荐
- VC防止程序被多次运行 互斥体方法
- 中国的大多数软件的一个bug和我眼中最保险的防止程序运行多次的方法
- vc 防止多次运行同一个程序的方法
- Win7系统中限制指定程序运行的实现方法
- 简单API实例限制程序多次运行
- 中国的大多数软件的一个bug和我眼中最保险的防止程序运行多次的方法
- vc 防止多次运行同一个程序的方法
- 限制程序只运行一次,再隐藏后重新唤出的方法。两个开发环境下实现
- .bat文件运行java程序的main方法
- javascript实现在网页中运行本地程序的方法
- 由于虚拟机监控程序未运行,无法启动 Windows Phone Emulator。可能原因是为打开硬件辅助虚拟化。的解决方法
- 使用sublime编辑器运行python程序的方法
- 使程序在Linux下后台运行 (关掉终端继续让程序运行的方法)
- 让程序在开机自动运行的好方法(收藏)
- MapReduce 程序运行报错 java.lang.ClassNotFoundException解决方法
- 模板方法模式——求程序运行时间
- 运行Shell程序的方法
- 使程序在Linux下后台运行 (关掉终端继续让程序运行的方法)
- 【转】delphi程序只允许运行一个实例的三种方法:
- 〖Android〗从Android Studio转为Eclipse开发项目运行程序闪退的解决方法