概述
单实例场景:仅允许启动一次应用程序,如果再次打开程序,则将已打开的程序前台显示;
全局外部函数
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