System Error Codes (WinError.h)

This section of the Microsoft Developer Network (MSDN) library provides detailed information about system error codes used in Windows. These codes are defined in the WinError.h header file and are returned by various Windows API functions to indicate the result of an operation.

Understanding Error Codes

When a Windows API function fails, it typically returns a value indicating the error. This value is often a numerical error code. These codes can be symbolic constants (e.g., ERROR_SUCCESS, ERROR_FILE_NOT_FOUND) or raw numerical values. The GetLastError() function is commonly used to retrieve the most recent error code set by a thread.

Common Error Code Categories

Error Code: 0x80070002 (2)

ERROR_FILE_NOT_FOUND

#define ERROR_FILE_NOT_FOUND ((DWORD) 0x00000002L)

Description: The system cannot find the file specified.

Context: This error code is returned when an operation attempts to access a file or directory that does not exist at the specified path. This can occur during file I/O operations, launching executables, or referencing configuration files.

Common Causes:

Related Functions:

Note: It's crucial to check the return value of Windows API functions and use GetLastError() to diagnose issues accurately.

Error Code: 0x80070005 (5)

ERROR_ACCESS_DENIED

#define ERROR_ACCESS_DENIED ((DWORD) 0x00000005L)

Description: Access is denied.

Context: This error code indicates that the calling process does not have the necessary permissions to perform the requested operation on a resource, such as a file, registry key, or system object.

Common Causes:

Related Functions:

Tip: When encountering ERROR_ACCESS_DENIED, verify the user's or process's security context and the resource's permissions. Consider running the application with elevated privileges if appropriate and authorized.

Finding More Error Codes

You can find a comprehensive list of system error codes in the Windows SDK documentation, typically in the WinError.h header file. Many online resources and tools also provide search functionality for these codes.

For a full list of system error codes, please refer to the official Windows SDK documentation or search specific error codes.

Important: Error codes can sometimes be platform or version-specific. Always ensure you are consulting documentation relevant to your target Windows version.