您正在看的Powerbuilder教程是:在PB中调用外部尘迅程序并判断其运行结束
在PB中经常要调用外部程序并等待此程序运行结束后显示相关信息 如我们要备份Adaptive Server Anywhere 数据库 在备份结束后显示 备份完成! 的提示信息 如果在调用备份铅虚程序dbbackup后马上用messagebox显示提示信息 那派激此么程序运行时则会出现这种情况 dbbackup备份程序还在运行 备份完成! 的提示就已经显示了 显然不符合我们的设想 对于这种情况 我们可以借助API函数FindWindowA() IsWindow()和PB本身函数yield()来解决
声明API函数
Function long FindWindowA (String lpClassName String lpWindowName ) Library user dll Function boolean IsWindow (Long hwnd ) Library user dll调用
ulong ll_handle int li_loop
SetPointer(HourGlass!) //设置鼠标指针 //运行备份数据库程序dbbackup 并使其最小化 run( dbbackup c ~ uid=dbapwd=sqldbf=D:\Sybase\Adaptive Server Anywhere \asademo db~ d:\backup Minimized!)
lishixinzhi/Article/program/PB/201311/24551
使用windows自带的团猛基库函数'kernel32.dll' ,来判断程序是否已经运行,示例如下:
//外部函数声明Function ulong GetLastError () library 'kernel32.dll'
Function ulong CreateMutexA (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library 'kernel32.dll'
//app 知数的open事件代码
string ls_mutex_name
ulong ll_mutex
ulong ll_err
if handle (GetApplication(),false) <> 0 then
ls_mutex_name = AppName
ll_mutex = CreateMutexA (0,0,ls_mutex_name)
ll_err = GetLastError()
if ll_err = 183 then
messagebox("","该程序正在运行塌谨")
Halt close
end if
end if
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)