|
Overview |
|
|
|
Group |
|
|
|
Quick Info
Windows NT
| Yes
| Win95
| Yes
| Win32s
| Yes
| Import Library
| kernel32.lib
| Header File
| winbase.h
| Unicode
| No
| Platform Notes
| None
|
|
|
SetLastError
The SetLastError function sets the last-error code for the calling thread.
VOID SetLastError(
DWORD dwErrCode
| // per-thread error code
| );
|
|
Parameters
dwErrCode
Specifies the last-error code for the thread.
Remarks
Error codes are 32-bit values (bit 31 is the most significant bit). Bit 29 is
reserved for application-defined error codes; no Win32 API error code has this
bit set. If you are defining an error code for your application, set this bit
to indicate that the error code has been defined by your application and to
ensure that your error code does not conflict with any system-defined error codes.
This function is intended primarily for dynamic-link libraries (DLLs). Calling
this function after an error occurs lets the DLL emulate the behavior of a
Win32 function.
Most Win32 functions call SetLastError when they fail. Function failure is typically indicated by a return value
error code such as FALSE, NULL, 0xFFFFFFFF, or 1. Some functions call SetLastError under conditions of success; those cases are noted in each function's
reference page.
Applications can retrieve the value saved by this function by using the GetLastError function. The use of GetLastError is optional; an application can call it to find out the specific reason for a
function failure.
The last-error code is kept in thread local storage so that multiple threads
do not overwrite each other's values.
See Also
GetLastError, SetLastErrorEx, TlsGetValue
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder
More Online Helps
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|