ISNMP::GetAsByte method
The GetAsByte
method enables an ASP Web page to get the value identified by an SNMP OID and to convert the value to an unsigned integer.
HRESULT GetAsByte(
[in] BSTR bstrOID,
[out] PUINT puValue
);
bstrOID [in]
A caller-supplied BSTR value that contains the SNMP OID.
puValue [out]
A caller-supplied pointer to a location that receives the unsigned integer value.
This method returns one of the values in the following table.
Return code | Description |
---|---|
S_OK | The operation succeeded. |
E_FAIL | The ISNMP::Open method has not been called. |
E_INVALIDARG | The specified SNMP OID is not valid. |
E_OUTOFMEMORY | Out of memory. |
This method calls the SnmpMgrRequest function to retrieve the value identified by an SNMP OID. Before the method passes the value to the caller, it converts the caller to an unsigned integer. For more information about SnmpMgrRequest, see the Windows SDK documentation.
For the following data types, the ISNMP::GetAsByte
method converts the scalar value identified by the SNMP OID to an equivalent unsigned integer value, which the caller receives:
ASN_INTEGER
ASN_RFC1155_COUNTER
ASN_RFC1155_GAUGE
ASN_RFC1155_TIMETICKS
ASN_UNSIGNED32
For the following data types, if the size of the value identified by the SNMP OID does not exceed two bytes, the method packs the beginning elements of the string, array, or opaque value into the unsigned integer value that the caller receives:
ASN_BITS
ASN_OCTETSTRING
ASN_RFC1155_OPAQUE
ASN_SEQUENCE
The method does not currently support conversions from data types other than those in the preceding lists. For more information about these data types, see the description of the SNMP Management API in the Windows SDK documentation.
The ISNMP::Open method must be called before the ISNMP::GetAsByte
method can be called.
Dim StrIP, strCommunity, objSNMP, OIDValue
strIP = Session("MS_IPaddress")
strCommunity = Session ("MS_Community")
Set objSNMP = Server.CreateObject("OlePrn.OleSNMP")
objSNMP.Open strIP, strCommunity, 2, 1000
OIDValue = objSNMP.GetAsByte ("25.3.5.1.2")
Target platform: Desktop
Header: Olesnmp.h