CreateMutexA 问题

zb63668331 2009-06-30 11:40:51
-----问题------------------------------------------------------
在pb10.5中
无论多少次运行,ll_err 始终为122,就是得不到183;
将ls_mutex_name 改为任一字符串,ll_err 还是为122;
而在PB8程序中调用正常
请高手指点
--------API申明--------------------------------------------------
function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library "kernel32.dll" alias for "CreateMutexA;Ansi"
function ulong GetLastError () library "kernel32.dll"
--------调用---------------------------------------------------------
ulong ll_mutex, ll_err
string ls_mutex_name

if handle (GetApplication (), false) <> 0 then
ls_mutex_name = this.AppName + CharA (0)
ll_mutex = CreateMutexA (0,0,ls_mutex_name)
ll_err = GetLastError ()
// MessageBox ("提示信息",string(ll_err)+'&'+ls_mutex_name+'&'+string(ll_mutex))
if ll_err = 183 then
MessageBox ("提示信息", "系统已经在运行中!")
Halt close
end if
end if
-----------等待------------------
???
...全文
356 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
WorldMobile 2009-06-30
  • 打赏
  • 举报
回复
如果不行的话,就用findwindowA来实现吧
zb63668331 2009-06-30
  • 打赏
  • 举报
回复
按理说第一次运行 ll_err 为0 才是,可是第一次运行就为122
可在PB8中是正常的
zb63668331 2009-06-30
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lzp_lrp 的回复:]
把你的ls_mutex_name = this.AppName + CharA (0)

改为
ls_mutex_name = 'powerbuilder15'

再试试
[/Quote]
改了不行,改成任何字符串ll_err 还是为122
zb63668331 2009-06-30
  • 打赏
  • 举报
回复
mutexhandle=ll_mutex
请解释一下这句
WorldMobile 2009-06-30
  • 打赏
  • 举报
回复
把你的ls_mutex_name = this.AppName + CharA (0)

改为
ls_mutex_name = 'powerbuilder15'

再试试
WorldMobile 2009-06-30
  • 打赏
  • 举报
回复
程序需要编译成exe后运行

ulong ll_mutex, ll_err
string ls_mutex_name
ls_mutex_name = as_modname
ll_mutex = CreateMutexA (0, 0, ls_mutex_name)
ll_err = GetLastError ()
mutexhandle=ll_mutex
if ll_err = 183 then
return 2
end if
return 0
wag_enu 2009-06-30
  • 打赏
  • 举报
回复
关于API的问题,可以上MSDN查查.
zb63668331 2009-06-30
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 xys_777 的回复:]
我也有10.5
刚才小小为lz 试了一下,有一些发现
function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, string lpName) library "kernel32.dll" alias for "CreateMutexA;Ansi"
这样定义就完全正常了。
function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library "kernel32.dll" alias for "CreateMutexA;Ansi"
这样多了ref就不能正常了



引…
[/Quote]
对的,谢谢了,分给你
永生天地 2009-06-30
  • 打赏
  • 举报
回复
我也有10.5
刚才小小为lz 试了一下,有一些发现
function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, string lpName) library "kernel32.dll" alias for "CreateMutexA;Ansi"
这样定义就完全正常了。
function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library "kernel32.dll" alias for "CreateMutexA;Ansi"
这样多了ref就不能正常了


[Quote=引用楼主 zb63668331 的帖子:]
-----问题------------------------------------------------------
在pb10.5中
无论多少次运行,ll_err 始终为122,就是得不到183;
将ls_mutex_name 改为任一字符串,ll_err 还是为122;
而在PB8程序中调用正常
请高手指点
--------API申明--------------------------------------------------
function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library "kernel32…
[/Quote]

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧