[This is preliminary documentation and subject to change.]
The WinSNMP SnmpOidToStr function converts the internal binary representation of an SNMP object identifier to its dotted numeric string format, for example, to "1.2.3.4.5.6".
SNMPAPI_STATUS SnmpOidToStr(
smiLPCOID srcOID, // object identifier to convert
smiUINT32 size, // buffer size for string
LPSTR string // pointer to buffer for converted string
// object identifier
);
If the function succeeds, the return value is the length, in bytes, of the string that the WinSNMP manager application writes to the string parameter. The return value includes a null-terminating byte. This value may be less than or equal to the value of the size parameter, but it may not be greater.
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 srcOID parameter is invalid. For additional information, see the following Remarks section. |
SNMPAPI_OUTPUT_TRUNCATED | The output buffer length is insufficient. |
SNMPAPI_OTHER_ERROR | An unknown or undefined error occurred. |
It is recommended that a WinSNMP manager application specify, with the size parameter, a string buffer of MAXOBJIDSTRSIZE length (1408 bytes). This ensures that the output buffer is large enough to hold the converted string. Because the converted string is usually less than MAXOBJIDSTRSIZE, the WinSNMP manager application can copy the converted string to a smaller buffer. The WinSNMP manager application can then reuse or free the memory that it allocated for the initial buffer. For additional information, see WinSNMP Data Management Concepts.
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, SnmpStrToOid, smiOID