您的位置:首页 > 其它

限制程序多次运行方法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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: