pb9 单实例运行,仅允许运行一个实例

概述

单实例场景:仅允许启动一次应用程序,如果再次打开程序,则将已打开的程序前台显示;

全局外部函数

Global External Functions

public Function long FindWindowA( ulong Winhandle, string wintitle ) Library "user32" 
public Function uLong ShowWindow( ulong winhandle, int wincommand ) Library "user32" 
public Function uLong BringWindowToTop( ulong HWND ) Library "user32" 
public Function Long SetForegroundWindow  (Long hwnd) Library "user32.dll" Alias For "SetForegroundWindow"

应用程序open事件

ulong l_handle, lu_class
string ls_name

ls_name = ProfileString("config.ini", "setting", "sys_title", this.appname) 
l_handle = FindWindowA(lu_class, ls_name)

if l_handle > 0 then	// 如果程序已运行,则直接打开
	yield();
	ShowWindow(l_handle, 1)
	BringWindowToTop(l_handle)
	SetForegroundWindow (l_handle)
	
	Halt Close
else
	open(w_main) //此处为系统主窗口
end if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值