请教如何限制重复运行同一个PB程序
答案:2 悬赏:80 手机版
解决时间 2021-01-24 23:32
- 提问者网友:两耳就是菩提
- 2021-01-24 13:42
请教如何限制重复运行同一个PB程序
最佳答案
- 五星知识达人网友:枭雄戏美人
- 2021-01-24 13:55
通过CreateMutexA函数创建一个互斥体,然后用GetLastError来获取返回值判断是否重复开启同一个应用。
外部函数声明
Function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library 'kernel32.dll'
Function ulong GetLastError () library 'kernel32.dll'APP的open事件代码
string ls_mutex_name
long ll_mutex
long ll_err
if handle (GetApplication(),false) <> 0 then
ls_mutex_name = this.AppName
ll_mutex = CreateMutexA (0,0,ls_mutex_name)
ll_err = GetLastError ()
if ll_err = 183 then
messagebox("","程序重复开启")
Halt close
end if
end if
open(w_open)
外部函数声明
Function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library 'kernel32.dll'
Function ulong GetLastError () library 'kernel32.dll'APP的open事件代码
string ls_mutex_name
long ll_mutex
long ll_err
if handle (GetApplication(),false) <> 0 then
ls_mutex_name = this.AppName
ll_mutex = CreateMutexA (0,0,ls_mutex_name)
ll_err = GetLastError ()
if ll_err = 183 then
messagebox("","程序重复开启")
Halt close
end if
end if
open(w_open)
全部回答
- 1楼网友:轮獄道
- 2021-01-24 14:12
虽然我很聪明,但这么说真的难到我了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯