在继续 MFC 类复制系列的同时(对于有知识的人),这里是 CEvent 类复制:
class CEvent {
HANDLE m_hEvent;
public:
CEvent(
BOOL bInitialState,
BOOL bManualReset)
{
LPSECURITY_ATTRIBUTES lpEventAttributes = NULL;
m_hEvent = CreateEvent(lpEventAttributes,
bManualReset,
bInitialState,
NULL);
}
~CEvent()
{
m_hEvent = NULL;
}
BOOL SetEvent()
{
return ::SetEvent(m_hEvent);
}
BOOL ResetEvent()
{
return ::ResetEvent(m_hEvent);
}
HANDLE GetHandle()
{
return m_hEvent;
}
operator HANDLE()
{
return m_hEvent;
}
};
代码已根据答案进行了编辑。