如何防止一个程序执行两次

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
如何防止一个程序执行两次
这是一个比较简单的防止程序执行两次的方法
implementation
var hnd: THandle;
initialization
hnd := CreateMutex(nil, True, 'irgendwaseinmaliges');
if GetLastError = ERROR_ALREADY_EXISTS then Halt;
finalization
if hnd <> 0 then CloseHandle(hnd);
end.
 
顶部