[This is preliminary documentation and subject to change.]
The WinSNMP SnmpGetLastError function returns the calling application's last-error code value. The value indicates the reason why the last function call executed by the WinSNMP manager application failed.
SNMPAPI_STATUS SnmpGetLastError(
HSNMP_SESSION session // handle to the WinSNMP session
);
A single thread manager application can pass a NULL session value to SnmpGetLastError to retrieve last-error information for the entire application. For additional information, see the following Return Values section.
If the session parameter is a valid WinSNMP session handle, the SnmpGetLastError function returns the last WinSNMP error that occurred for the indicated session.
If the session parameter is NULL — for example, if the SnmpStartup function fails, SnmpGetLastError returns the last WinSNMP error that occurred for the entire manager application.
A WinSNMP manager application must call SnmpGetLastError immediately after a function fails, to retrieve the last-error code. If another function fails, it overwrites the last-error code set by the most recently failed function.
Although the session parameter accommodates both multithread and single-thread Windows operating environments, the potential still exists for the last-error code from one thread to overwrite the last-error code from another thread.
Note that SnmpGetLastError must be able to return the last-error code to a WinSNMP manager application under the following conditions:
Windows NT: Requires version 5.0 or later. Available as a redistributable for Windows NT 4.0.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winsnmp.h.
Import Library: Use wsnmp32.lib.
WinSNMP Manager API Overview, WinSNMP Functions, SnmpStartup, SnmpOpen, SnmpClose, SnmpCleanup