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 "1.2.3.4.5.6".

Syntax

SNMPAPI_STATUS SNMPAPI_CALL SnmpOidToStr(
  [in]  smiLPCOID srcOID,
  [in]  smiUINT32 size,
  [out] LPSTR     string
);

Parameters

[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
SNMPAPI_NOT_INITIALIZED
The SnmpStartup function did not complete successfully.
SNMPAPI_ALLOC_ERROR
An error occurred during memory allocation.
SNMPAPI_SIZE_INVALID
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.
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.

Remarks

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.

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

See also

SnmpStrToOid

WinSNMP Functions

WinSNMP API Overview

smiOID