Re: Joe's ErrorString-fn in german environment...?
a socket is returning WSAECONNABORTED (= 10053) , and that is
perfectly well 'cos i do exactly what is described at msdn: "Software
caused connection abort". But when i call joes fn, i get "Ger?t oder
Adresse nicht vorhanden" (in english this would be something like
"device or adress does not exist"). So the question is...
could please someone with english environment
check this fn on WSAECONNABORTED?
On my Vista SP1, English U.S. I get "No such device or address"
But I don't understand why do you bother with the module and
FORMAT_MESSAGE_FROM_HMODULE?
Just call the thing with NULL and forget FORMAT_MESSAGE_FROM_HMODULE
and you will get
"An established connection was aborted by the software in your host machine"
And I normally go with MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
instead of 0.
So:
//---------------------------------------------------------------
// Translate an error-code from winsock- or system-message-table
bool ErrorString(DWORD errorCode, CString& scString)
{
DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM;
LPTSTR msg;
bool fRet = (::FormatMessage(flags, NULL, errorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&msg, 0, NULL) != 0);
if (fRet)
{
// remove ending CR and append a NUL
LPTSTR eol = _tcsrchr(msg, _T('\r'));
if(eol != NULL)
*eol = _T('\0');
scString = msg;
}
LocalFree(msg);
return fRet;
}
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email