Ansis Māliņš
Ansis Māliņš

Reputation: 1712

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?

Upvotes: 0

Views: 146

Answers (1)

David Heffernan
David Heffernan

Reputation: 613013

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.

Upvotes: 3

Related Questions