[2013-07-01] 최근 버전에서는 TMutex 를 이용하여 간단하게 할 수 있다.
#include <System.SyncObjs.hpp>
SECURITY_ATTRIBUTES SecAttr;
char SecDesc[[SECURITY_DESCRIPTOR_MIN_LENGTH];
SecAttr.nLength = sizeof(SecAttr);
SecAttr.bInheritHandle = FALSE;
SecAttr.lpSecurityDescriptor = &SecDesc;
::InitializaSecurityDescriptor(SecAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
::SetSecurityDescriptorDacl(SecAttr.lpSecurityDescriptor, TRUE, 0, FALSE);
try {
TMutex *pMutex = new TMutex(&SecAttr, true, AMutexName, false);
} catch (...) {
return 0;
}
if (pMutex->WaitFor(100) != wrSignaled)
return 0;
// TODO: Something
pMutex->Release();
delete pMutex;
'Windows > RAD Studio' 카테고리의 다른 글
[JS] ScrollObject (0) | 2007.09.21 |
---|---|
[DEL] Mutex 를 이용한 실행중복 방지 (0) | 2007.09.21 |
[CB] KeyPad Virtual Key Value (0) | 2007.06.09 |
[DEL] Deprecated Lists (0) | 2007.06.02 |
[CB] 문자열 변환/검증 (0) | 2007.05.30 |