Discussion:
FormatMessage()-equivalent for WinHttp?
(too old to reply)
Jason Viers
2007-07-20 15:35:49 UTC
Permalink
Is there any built-in way to turn WinHttp error codes into strings?
Most Win32 code uses FormatMessage[1], but it appears that it doesn't
know about winhttp codes, and some of the codes
(WINHTTP_CALLBACK_STATUS_FLAG_*) collide with existing error codes.

I know I can manually embed my own switch/case for them, but that's
rather ugly. Is there a more elegant way to do it?

Thanks
Jason

[1] http://msdn2.microsoft.com/en-us/library/ms679351.aspx
Stephen Sulzer
2007-07-23 03:30:07 UTC
Permalink
Hello Jason,

FormatMessage can get strings for the WinHttp error codes; however you must
point FormatMessage to the winhttp.dll module, where the error strings are
stored:

FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
GetModuleHandle("winhttp.dll"),
dwWinHttpErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
pBuffer,
cchBufferSize,
NULL);

The WINHTTP_CALLBACK_STATUS_ values are not Win32 error codes; there is no
string table resource for them.

Regards,
Stephen
Jason Viers
2007-07-23 14:13:48 UTC
Permalink
Post by Stephen Sulzer
Hello Jason,
FormatMessage can get strings for the WinHttp error codes; however you must
point FormatMessage to the winhttp.dll module, where the error strings are
I had just found that before this reply was posted. :)
Post by Stephen Sulzer
The WINHTTP_CALLBACK_STATUS_ values are not Win32 error codes; there is no
string table resource for them.
Ok, that's certainly better than doing it for all of them.

Thanks!
Jason

Loading...