I mean these: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

Here are three pieces of data to every error:

0 (0x0)
ERROR_SUCCESS
The operation completed successfully.

1 (0x1)
ERROR_INVALID_FUNCTION
Incorrect function.

2 (0x2)
ERROR_FILE_NOT_FOUND
The system cannot find the file specified.

So, the error number is returned from GetLastError(), I know also how to get the description using FormatMessage http://msdn.microsoft.com/en-us/library/windows/desktop/ms679351(v=vs.85).aspx . But my question is how to get these error flags : ERROR_INVALID_FUNCTION, ERROR_FILE_NOT_FOUND - as strings. I know that I can create a map for that myself, but I wonder if these are not already stored somewhere within windows just as error descriptions are.

[OT] here is snippet for error descriptions.

char *err_msg;
int num_chars = FormatMessage(
  FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  NULL,
  errCode,
  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
  (LPTSTR) &err_msg,
  0,
  NULL
);
有帮助吗?

解决方案

There is no such method built into Windows.

The #define identifiers are specific to C and C++ languages and are not used on e.g., C#. Another thing to note is that there can be multiple different #define's for the same error code depending on API used, such as ERROR_INVALID_HANDLE (Win32) and WSA_INVALID_HANDLE (Winsock).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top