Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Why does Windows use SetLastError/GetLastError Posted by f7sharp9 on 15 Dec 2008 at 4:53 PM
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.
Report
Re: Why does Windows use SetLastError/GetLastError Posted by AsmGuru62 on 16 Dec 2008 at 6:02 AM
: 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.
:
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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.