SnmpCleanupEx function (winsnmp.h)
[SNMP is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use Windows Remote Management, which is the Microsoft implementation of WS-Man.]
The SnmpCleanupEx function performs cleanup when there are no outstanding successful calls to SnmpStartup or SnmpStartupEx within a Windows SNMP (WinSNMP) application. Otherwise, an internal reference count indicating the current number of outstanding successful calls to SnmpStartupEx is decremented.
This function should be used instead of SnmpCleanup if Windows Server 2003 with Service Pack 1 (SP1) or later is installed. SnmpCleanupEx enables support for multiple independent software modules that use WinSNMP within the same application.
Syntax
SNMPAPI_STATUS SNMPAPI_CALL SnmpCleanupEx();
Return value
If the function succeeds, the return value is SNMPAPI_SUCCESS. Until the WinSNMP application successfully recalls the corresponding SnmpStartupEx function and there are no additional outstanding successful calls to either SnmpStartup or SnmpStartupEx, any other call to a WinSNMP function within the same application 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 SnmpCleanupEx. 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.
Return code | Description |
---|---|
|
An error occurred during memory allocation. |
|
The SnmpStartupEx function did not complete successfully, or an unknown or undefined error occurred. |
Remarks
Before the WinSNMP application calls SnmpCleanupEx, 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 SnmpCleanupEx function, the implementation deallocates all resources allocated to the application if there are also no outstanding successful calls to either SnmpStartup or SnmpStartupEx. 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 SnmpCleanupEx 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 SnmpCleanupEx.
SnmpCleanupEx must not be called when the application DLL is in the process of unloading.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winsnmp.h |
Library | Wsnmp32.lib |
DLL | Wsnmp32.dll |