1、声明外部函数
Function Long CreateMutexA(long lpMutexAttributes,boolean bInitialOwner , String lpName)Library "kernel32.dll"
Function Long GetLastError()Library "kernel32.dll"
2、代码
//--------------------------------------------------------------------//
//功能 :防止程序二次运行
// 该模块在程序编译后方有效
//编写日期:2013-03-08
//编者 :
string ls_s
long ll_ret
IF Handle(GetApplication())<>0 THEN
ls_s="mutex_name"
ll_ret=CreateMutexA(0,false,ls_s)
ll_ret=GetLastError()
if ll_ret<>0 then
messagebox("系统提示","本程序已经运行,您不能再打开它!")
halt
return
end if
end if