FormatMessage()
doesn't work for me no matter what I do. When I have error 12002, lpBuffer
returns as NULL all the time. This is my code:
LPTSTR lpBuffer = NULL;
DWORD dwError = GetLastError();
int nResult = 0;
if (dwError >= 12000 && dwError <= 12174)
{
nResult = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE,
GetModuleHandle("wininet.dll"), dwError, 0, (LPTSTR)&lpBuffer, 0, NULL);
}
else
{
nResult = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpBuffer, 0, NULL);
}
Does anyone have any ideas?