mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 12:29:56 +00:00
[ATL]
- Implement CHandle svn path=/trunk/; revision=70217
This commit is contained in:
parent
95fa8202a5
commit
bc3c1a8ed6
1 changed files with 74 additions and 0 deletions
|
@ -232,6 +232,80 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CHandle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HANDLE m_handle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CHandle() :
|
||||||
|
m_handle(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CHandle(_Inout_ CHandle& handle) :
|
||||||
|
m_handle(NULL)
|
||||||
|
{
|
||||||
|
Attach(handle.Detach());
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit CHandle(_In_ HANDLE handle) :
|
||||||
|
m_handle(handle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~CHandle()
|
||||||
|
{
|
||||||
|
if (m_handle)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CHandle& operator=(_Inout_ CHandle& handle)
|
||||||
|
{
|
||||||
|
if (this != &handle)
|
||||||
|
{
|
||||||
|
if (m_handle)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
Attach(handle.Detach());
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator HANDLE() const
|
||||||
|
{
|
||||||
|
return m_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Attach(_In_ HANDLE handle)
|
||||||
|
{
|
||||||
|
ATLASSERT(m_handle == NULL);
|
||||||
|
m_handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE Detach()
|
||||||
|
{
|
||||||
|
HANDLE handle = m_handle;
|
||||||
|
m_handle = NULL;
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Close()
|
||||||
|
{
|
||||||
|
if (m_handle)
|
||||||
|
{
|
||||||
|
::CloseHandle(m_handle);
|
||||||
|
m_handle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline BOOL WINAPI InlineIsEqualUnknown(REFGUID rguid1)
|
inline BOOL WINAPI InlineIsEqualUnknown(REFGUID rguid1)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue