Platform SDK: Network Management

SnmpOidCopy

The WinSNMP SnmpOidCopy function copies an SNMP object identifier, allocating any necessary memory for the copy.

SNMPAPI_STATUS SnmpOidCopy(
  smiLPCOID srcOID,      // source object identifier 
  smiLPOID dstOID        // destination object identifier 
);

Parameters

srcOID
[in] Pointer to an smiOID structure to copy.
dstOID
[out] Pointer to an smiOID structure to receive a copy of the object identifier specified by the srcOID parameter.

Return Values

If the function succeeds, the return value is the number of subidentifiers in the copied object identifier. This number is also the value of the len member of the smiOID structure pointed to by the dstOID parameter.

If the function fails, the return value is SNMPAPI_FAILURE. 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_OID_INVALID The srcOID parameter is invalid.
SNMPAPI_OTHER_ERROR An unknown or undefined error occurred.

Remarks

On input, the SnmpOidCopy function ignores the members of the smiOID structure pointed to by the dstOID parameter. The Microsoft WinSNMP implementation overwrites the smiOID members if the function completes successfully.

The WinSNMP application must call the SnmpFreeDescriptor function to enable the implementation to free resources allocated for the ptr member of the smiOID structure pointed to by the dstOID parameter. For additional information, see WinSNMP Data Management Concepts and Freeing WinSNMP Descriptors.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winsnmp.h.
  Library: Use Wsnmp32.lib.

See Also

WinSNMP API Overview, WinSNMP Functions, SnmpFreeDescriptor, smiOID