在開發過程中可以使用互斥對象控制應用程序只能打開一個進程
if OpenMutex(MUTEX_ALL_ACCESS
begin
CreateMutex(nil
Application
Application
Application
CloseHandle(OpenMutex(MUTEX_ALL_ACCESS
end;
使用CreateMutex函數創建互斥對象
語法格式如下
Handle CreateMutex(
LPSECURITY_ATTRIBUTES lpMutexAttributes
BOOL bInitialOwner
LPCTSTR lpName
);
參數說明
lpMutexAttributes
BInitialOwner
LpName
Return_Value
使用OpenMutex函數打開互斥對象
語法格式如下
Handle OpenMutex(
DWORD dwDesiredAccess
BOOL bInheritHandle
LPCTSTR lpName // pointer to mutex
);
參數說明
dwDesiredAccess
BInheritHandle
LpName
Return_Value
From:http://tw.wingwit.com/Article/program/Delphi/201311/24892.html