handle.cpp
来自「IO函数调用测试」· C++ 代码 · 共 35 行
CPP
35 行
#include "stdafx.h"
#include "TraceEvent.h"
#include "handle.h"
int CHandle::count = 0;
/****************************************************************************
* CHandle::closeTheHandle
* Result: void
*
* Effect:
* This is actually the body of the destructor, but the C++
* compiler erroneously diagnoses the __try/__finally as being illegal
* in a destructor, so by moving it out to a separate method and
* calling that method from the destructor we avoid this compiler bug.
****************************************************************************/
void CHandle::closeTheHandle()
{
__try {
::CloseHandle(h);
}
__except(EXCEPTION_EXECUTE_HANDLER) // STATUS_INVALID_HANDLE exception
{
// ignore it!
}
}
CHandle::~CHandle()
{
if(h == NULL)
return;
closeTheHandle();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?