프로그래밍/Windows
윈도우즈 에러 핸들링 GetLasterror / FormatMessage
즉흥
2014. 4. 30. 15:50
728x90
반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include<Windows.h> #include<iostream> int main(){ DWORD dwError = GetLastError(); HLOCAL hlocal = NULL; //언어 설정 DWORD systemLocale = MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN); FormatMessage( //운영체제에 정의된 에러 코드를 가져온다. FORMAT_MESSAGE_FROM_SYSTEM | //%를 자리 표시자로 사용 안 함(%s, %c 등을 무시). FORMAT_MESSAGE_IGNORE_INSERTS | //메모리 공간을 할당 FORMAT_MESSAGE_ALLOCATE_BUFFER, //모르겠다. NULL, //에러 코드 입력 dwError, //출력할 언어 설정, 0이면 운영체제 기본 언어로 세팅된다. systemLocale, //에러 메시지를 입력할 버퍼 (PTSTR)&hlocal, //버퍼에 담을 메시지 크기 0, //모르겠다. NULL); MessageBox(NULL, (PCTSTR)LocalLock(hlocal), L"ErrorMsg", MB_OK); LocalFree(hlocal); return 0; } |
DWORD WINAPI FORMATMESSAGE ( _In_ DWORD dwFlags에, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _Out_ LPTSTR lpBuffer, _In_ DWORD n 크기, _In_opt_의 va_list *이 인수
);
WORD MAKELANGID( USHORT usPrimaryLanguage, USHORT usSubLanguage
);
http://msdn.microsoft.com/
여태 에러 메시지를 함수를 이용해서 확인해본적은 없으나 알아서 나쁠 것은 없겠다 싶어서 올림.
728x90
반응형