SnmpStrToOid

[This is preliminary documentation and subject to change.]

The WinSNMP SnmpStrToOid function converts the dotted numeric string format of an SNMP object identifier, for example, "1.2.3.4.5.6", to its internal binary representation.

SNMPAPI_STATUS SnmpStrToOid(
  LPCSTR string,      // string object identifier to convert 
  smiLPOID dstOID     // object identifier internal representation 
);
 

Parameters

string
Pointer to a null-terminated object identifier string to convert.
dstOID
Pointer to an smiOID structure that receives the converted value.

Return Values

If the function succeeds, the return value is the number of subidentifiers in the converted 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. 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 string parameter is invalid. For additional information, see the following Remarks section.
SNMPAPI_OTHER_ERROR An unknown or undefined error occurred.

Remarks

The WinSNMP manager application must call the SnmpFreeDescriptor function to free resources allocated for the ptr member of the smiOID structure pointed to by the dstOID parameter. On input, SnmpFreeDescriptor ignores the members of this smiOID structure. The Microsoft WinSNMP implementation overwrites the smiOID members if the function completes successfully.

The SnmpStrToOid function fails and returns the SNMPAPI_OID_INVALID error code if the string parameter meets one of the following conditions:

For additional information, see WinSNMP Data Management Concepts and Freeing WinSNMP Descriptors.

QuickInfo

  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.

See Also

WinSNMP Manager API Overview, WinSNMP Functions, SnmpFreeDescriptor, smiOID