Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

30 lines
750 B

#pragma once
#include "SpAutoHandle.h"
class CSpAutoMutex : public CSpAutoHandle
{
public:
HRESULT InitMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName)
{
SPDBG_ASSERT(m_h == NULL);
m_h = g_Unicode.CreateMutex(lpMutexAttributes, bInitialOwner, lpName);
return (m_h) ? S_OK : SpHrFromLastWin32Error();
}
BOOL ReleaseMutex()
{
SPDBG_ASSERT(m_h);
return ::ReleaseMutex(m_h);
}
HRESULT HrReleaseMutex()
{
SPDBG_ASSERT(m_h);
if (::ReleaseMutex(m_h))
{
return S_OK;
}
return SpHrFromLastWin32Error();
}
};