Why does Windows use SetLastError/GetLastError - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Why does Windows use SetLastError/GetLastError

Why does the Windows API use the SetLastError/GetLastError model instead of just having functions return success or an error code? Is there any reason someone writing their own API for Win32 should use the Get/Set LastError model instead of just returning sucess or error code? Thanks.

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Why does the Windows API use the SetLastError/GetLastError model
    : instead of just having functions return success or an error code? Is
    : there any reason someone writing their own API for Win32 should use
    : the Get/Set LastError model instead of just returning sucess or
    : error code? Thanks.
    :
    [color=Blue]The Win API is designed to return a TRUE/FALSE code as a signal of success or failure. A lot of APIs return a handle or pointer, which can be NULL or non-NULL value. This also translates to a success or failure return code.

    The ability to give the real reason of success or failure is very good for extending the API in next versions of Win API.[/color]
Sign In or Register to comment.