물에 사는 벌레
FormatMessage 본문
DWORD FormatMessage(
DWORD dwFlags,
LPCVOID lpSource,
DWORD dwMessageId,
DWORD dwLanguageId,
LPTSTR lpBuffer,
DWORD nSize,
va_list *Arguments
);
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf, 0, NULL);
// lpMsgBuf에 담긴 오류 내용을 지지고 볶기...
LocalFree(lpMsgBuf);
}
FORMAT_MESSAGE_ALLOCATE_BUFFER: 지정한 버퍼에 할당하기(윈도우는 절대 자신의 변수에 접근을 허용하지 않아 HANDLE, 또는 복사하여 할당하는 방법을 사용)
FORMAT_MESSAGE_FROM_SYSTEM, 메세지를 시스템에서 가져오기
WSAGetLastError(): 마지막 에러 가져오기
LocalFree(...): 복사하여 할당한 버퍼 반환
Comments