SnmpOidToStr 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 WinSNMP SnmpOidToStr function converts the internal binary representation of an SNMP object identifier to its dotted numeric string format, for example, to "".


  [in]  smiLPCOID srcOID,
  [in]  smiUINT32 size,
  [out] LPSTR     string


[in] srcOID

Pointer to an smiOID structure with an object identifier to convert.

[in] size

Specifies the size, in bytes, of the buffer indicated by the string parameter. For more information, see the following Remarks section.

[out] string

Pointer to a buffer to receive the converted string object identifier that specifies the SNMP management entity.

Return value

If the function succeeds, the return value is the length, in bytes, of the string that the WinSNMP 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 specifying a NULL value in its session parameter. The SnmpGetLastError function can return one of the following errors.

Return code Description
The SnmpStartup function did not complete successfully.
An error occurred during memory allocation.
The size parameter is invalid. This parameter cannot be equal to zero; it must indicate the size of the buffer pointed to by the string parameter.
The srcOID parameter is invalid. For additional information, see the following Remarks section.
The output buffer length is insufficient.
An unknown or undefined error occurred.


It is recommended that a WinSNMP 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 application can copy the converted string to a smaller buffer. The application can then reuse or free the memory that it allocated for the initial buffer. For additional information, see WinSNMP Data Management Concepts.


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

See also


WinSNMP Functions

WinSNMP API Overview