2023-12-22 03:26:43 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Cicero
|
|
|
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
|
|
|
* PURPOSE: Cicero event object handling
|
|
|
|
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cicbase.h"
|
|
|
|
|
|
|
|
class CicEvent
|
|
|
|
{
|
|
|
|
HANDLE m_hEvent;
|
2023-12-26 03:07:01 +00:00
|
|
|
LPCTSTR m_pszName;
|
2023-12-22 03:26:43 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CicEvent() : m_hEvent(NULL), m_pszName(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
~CicEvent()
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2023-12-26 03:07:01 +00:00
|
|
|
BOOL Create(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszName)
|
2023-12-22 03:26:43 +00:00
|
|
|
{
|
|
|
|
if (pszName)
|
|
|
|
m_pszName = pszName;
|
|
|
|
if (!m_pszName)
|
|
|
|
return FALSE;
|
2023-12-26 03:07:01 +00:00
|
|
|
m_hEvent = ::CreateEvent(lpSA, FALSE, FALSE, m_pszName);
|
2023-12-22 03:26:43 +00:00
|
|
|
return (m_hEvent != NULL);
|
|
|
|
}
|
2023-12-26 03:07:01 +00:00
|
|
|
BOOL Open(LPCTSTR pszName)
|
2023-12-22 03:26:43 +00:00
|
|
|
{
|
|
|
|
if (pszName)
|
|
|
|
m_pszName = pszName;
|
2023-12-26 03:07:01 +00:00
|
|
|
m_hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, m_pszName);
|
2023-12-22 03:26:43 +00:00
|
|
|
return (m_hEvent != NULL);
|
|
|
|
}
|
|
|
|
void Close()
|
|
|
|
{
|
|
|
|
if (m_hEvent)
|
|
|
|
{
|
|
|
|
::CloseHandle(m_hEvent);
|
|
|
|
m_hEvent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL Wait(DWORD dwMilliseconds)
|
|
|
|
{
|
|
|
|
return (::WaitForSingleObject(m_hEvent, dwMilliseconds) == WAIT_OBJECT_0);
|
|
|
|
}
|
|
|
|
};
|