我需要获取从 GetLastError 函数获得的错误代码的文本。
我看到了一些示例,但我想要一个获取代码并返回字符串的函数。
谢谢大家
我猜你想要这样的东西:
DWORD dwLastError = ::GetLastError();
TCHAR lpBuffer[256] = _T("?");
if(dwLastError != 0) // Don't want to see a "operation done successfully" error ;-)
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, // It´s a system error
NULL, // No string to be formatted needed
dwLastError, // Hey Windows: Please explain this error!
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), // Do it in the standard language
lpBuffer, // Put the message here
STR_ELEMS(lpBuffer)-1, // Number of bytes to store the message
NULL);
另请参阅:http://msdn.microsoft.com/en-us/library/ms679351(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms679351(VS.85).aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)