| 发表于:2007-06-08 22:54:565楼 得分:0 |
function checkmutex(mutexname: string): boolean; begin result := openmutex(mutex_all_access, false, pchar(mutexname)) = 0; end; // 检查互斥,保证仅有一个实例存在。 if checkmutex(res_mutexname) then begin // 建立互斥标识。 hmutex := createmutex(nil, true, pchar(res_mutexname)); application.initialize; application.createform(tfmain, fmain); application.run; // 销毁互斥标识 releasemutex(hmutex); end; | | |
|