Retrieving the Last-Error Code

When a function in the Win32 API fails, it sets the last-error code. If your application needs more details about an error, it can retrieve the last-error code.

The following example shows an error-handling function.

  • oid error(LPSTR lpszFunction)

{

CHAR szBuf[80];

DWORD dw = GetLastError();

sprintf(szBuf, "%s failed: GetLastError returned %u\n",

lpszFunction, dw);

MessageBox(NULL, szBuf, "ERROR", MB_OK);

ExitProcess(dw);

}

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database