I'm doing some programming in Win32 + WTL, and I'm confused with the available types of errors.
In general, I want to check for an error, and feed it to AtlGetErrorDescription (which calls FormatMessage).
My questions are:
What's the difference between:
DWORD
, returned byGetLastError
.HRESULT
, returned by e.g. theCAtlFile
wrapper, which usesHRESULT_FROM_WIN32
to convert fromDWORD
.LSTATUS
, returned by e.g.RegCreateKeyEx
.
Which types of errors can I feed to
FormatMessage
? Its signature indicates it acceptsHRESULT
, but there are lots of examples where the return value ofGetLastError
is directly passed toFormatMessage
.
FormatMessage
can handle bothGetLastError()
andHRESULT_FROM_WIN32(GetLastError())
? Also, I don't understand why sometimes ATL wrappers return the WINAPI error code (e.g.CRegKey
), and sometimes theHRESULT
code (e.g.CAtlFile
). Is it OK to keep either result in, say, a DWORD, and pass the error, if any, toFormatMessage
? – Shumate