谁用解释一下GetLastError()的用法比如下面这个函数,GetLastError()返回的是什么?
BOOL CIni::DelSection(LPCTSTR lpSection) //删除段名
{
if(WritePrivateProfileString(lpSection,NULL,NULL,m_strFileName))
return FALSE;
else
return GetLastError();
}
BOOL CIni::DelSection(LPCTSTR lpSection) //删除段名
{
if(WritePrivateProfileString(lpSection,NULL,NULL,m_strFileName))
return FALSE;
else
return GetLastError();
}
当你检测到这些函数失败后,就可以调用GetLastError来获取具体的错误码,像下面这样int nBytes;
nBytes = recv(......);
if(nBytes == SOCKET_ERROR)
{
int nErrorCode = GetLastError();
printf("recv函数调用错误,错误码:%d", nErrorCode);
}
然后你就可以根据这个错误码去查找具体的错误信息了。
Error Lookup
位置在\Microsoft Visual Studio\Common\Tools\ERRLOOK.EXE
可以输入GetLastError()返回值查看错误类型
顺便膜拜2楼的五星级酒店,啊不,五星级前辈