GetModuleHandle获取到的句柄是不用closehandle的

GetModuleHandle获取到的句柄是不用closehandle的
void FixWorkingDir()
{
HANDLE hCurrentExe = ::GetModuleHandle(NULL);
std::tstring strFileName;
std::tstring strPath;
strFileName.resize(MAX_PATH*2, 0);
::GetModuleFileName((HMODULE)hCurrentExe, const_cast<TCHAR*>(strFileName.data()), strFileName.size());
auto nPosEnd = strFileName.find_last_of(_T('\\'));
if (std::tstring::npos != nPosEnd)
{
strPath = strFileName.substr(0, nPosEnd);
::SetCurrentDirectory(strPath.c_str());
}
else
{
XASSERT_MSG(false, _T("windows did not have root path, \\ must be found"));
}
}

你可能感兴趣的:(GetModuleHandle获取到的句柄是不用closehandle的)