Exaustive lists of all possible errors for various Windows API calls?
CreateFile
for example. When I get INVALID_HANDLE_VALUE
, what are all the possible values that can be returned by GetLastError
? MSDN doesn't say. It mentions some and I can guess others, but how (if at all) can I be sure that my switch
statement 开发者_运维技巧will never reach default
?
Such a list doesn't exist and in fact you can't ever have such a list. In some future version of Windows a function may well start returning an error code that did not exist when you compiled your program.
The standard way to deal with this is handle any error codes that you know about that need special treatment, and let all others fall through to a default handler. Call FormatMessage()
to get a descriptive text string for the error.
精彩评论