INFO: GetLastError() Differs Between Windows (127991)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
    • the operating system: Microsoft Windows 95
    • the operating system: Microsoft Windows 98
    • the operating system: Microsoft Windows Millennium Edition
    • the operating system: Microsoft Windows NT 3.51
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows XP

This article was previously published under Q127991

SUMMARY

The extended error codes returned by the GetLastError() API are not guaranteed to be the same under the operating systems listed at the beginning of this article. This difference applies to extended error codes generated by calls to GDI, Window Management, and System Services APIs.

The set of potential error codes returned by any particular Win32 API depends on many underlying components, including system kernel-mode components and loaded drivers. The extended error codes are not a part of the Win32 specification. Therefore, they can change as operating system and driver code is changed.

It is impossible to get the error codes for each API in synch across operating system and platforms. The above listed operating systems have different code bases. Third-party drivers return error codes that are mapped to Win32 error codes. In addition, it would be difficult to accurately maintain error code information in the Win32 Programmer's Reference. Therefore, this information is not included in the documentation.

In general, you should not rely on GetLastError() returning the same values under Microsoft Windows 95, Microsoft Windows 98, Microsoft Windows Millennium Edition (Me), and Microsoft Windows NT. Sometimes, an API will fail and GetLastError() will return 0 (ERROR_SUCCESS) under Windows 95/98/Me. This is because some of the APIs do not set error codes under Windows 95/98/Me.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbAPI kbGDI kbinfo kbKernBase KB127991