winapi의 오류를 문자열로 출력하기.
Posted by Go crazy for anything that will make you smile.
win api의 실패시 오류값은 dword. 내부로 들어가보면 알수없는 숫자들이 많다. 이를 문자열로 전화해서 출력하기 위해 GetLastError으로 에러 숫자코드를 받아 FormatMessage를 사용하여 바꾸어 준다. #include void PrintError(DWORD dwErrorNo); ... void PrintError(DWORD dwErrorNo) { LPVOID lpMsgBuf; if (!FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorNo, MAKELANGID(LANG_NEUTRAL, SUBLAN..