Platform SDK: Network Management |
The SnmpCleanup function informs the Microsoft WinSNMP implementation that the calling WinSNMP application no longer requires the implementation's services.
Note A WinSNMP application must call the SnmpCleanup function as the last WinSNMP function before it terminates.
SNMPAPI_STATUS SnmpCleanup(VOID);
This function has no parameters.
If the function succeeds, the return value is SNMPAPI_SUCCESS. Until the WinSNMP application successfully recalls the SnmpStartup function, any other call to a WinSNMP function returns SNMPAPI_FAILURE, with an extended error code of SNMPAPI_NOT_INITIALIZED.
If the function fails, the return value is SNMPAPI_FAILURE, but the WinSNMP application does not need to retry the call to SnmpCleanup. To get extended error information, call SnmpGetLastError specifying a NULL value in its session parameter. The SnmpGetLastError function can return one of the following errors.
Error Code | Description |
---|---|
SNMPAPI_NOT_INITIALIZED | The SnmpStartup function did not complete successfully. |
SNMPAPI_ALLOC_ERROR | An error occurred during memory allocation. |
SNMPAPI_OTHER_ERROR | An unknown or undefined error occurred. |
Before the WinSNMP application calls SnmpCleanup, it should call the SnmpClose function once for each session the implementation opens as a result of a call to the SnmpCreateSession function.
When a WinSNMP application calls the SnmpCleanup function, the implementation deallocates all resources allocated to the application. However, it is recommended that a WinSNMP application free the specific resources that the implementation allocates for it with the WinSNMP function that corresponds to the resource. For additional information about freeing individual resources, see SnmpFreeEntity, SnmpFreeVbl, SnmpFreeDescriptor, SnmpFreeContext, and SnmpFreePdu.
If a WinSNMP application must perform an emergency exit, and it calls SnmpCleanup without freeing individual resources and without calling SnmpClose for every open session, the implementation deallocates all resources allocated to the WinSNMP application. However, to enable this functionality in the implementation, the application must still call SnmpCleanup.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winsnmp.h.
Library: Use Wsnmp32.lib.
WinSNMP API Overview, WinSNMP Functions, SnmpCreateSession, SnmpStartup, SnmpClose, SnmpFreeEntity, SnmpFreeVbl, SnmpFreeDescriptor, SnmpFreeContext, SnmpFreePdu