Last Error (informática)


Last Error in computing, specifically in the field of programming in Windows is known as Last Error to the last error happened when using one of the Windows APIs. The error codes are particular to each thread that is running.

When an Api fails, it is very common to return NULL or -1. You can also log the error to be identified by the program that uses it. This is obtained by making a call to the GetLastError API, which returns the error code. Another way is to directly use the TIB, although this method can be cumbersome or even impossible in some high level languages.

A proper function or a default Windows program can make use of the Api SetLastError to report that error has occurred or in the case of no error can be used to reset the last error occurred. Once this is done, the error of the previously used function can not be determined. These errors are 32-bit integers. If you want to use SetLastError for "new" own errors of the application you must activate bit 29 since the system does not use errors with that bit enabled. In DELPHI function SampleError (error: DWORD): String; where pString: array [0..MAX_PATH] of char; begin FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, Nil, error, 0, pString, MAX_PATH, Nil); Result: = pString; end;



wiki

Popular Posts