SnmpMgrCtl function (mgmtapi.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 SnmpMgrCtl function sets an operating parameter associated with an SNMP session. This function is an element of the SNMP Management API.

Syntax

BOOL SNMP_FUNC_TYPE SnmpMgrCtl(
  [in]  LPSNMP_MGR_SESSION session,
  [in]  DWORD              dwCtlCode,
  [in]  LPVOID             lpvInBuffer,
  [in]  DWORD              cbInBuffer,
  [out] LPVOID             lpvOUTBuffer,
  [out] DWORD              cbOUTBuffer,
  [out] LPDWORD            lpcbBytesReturned
);

Parameters

[in] session

Pointer to an internal structure that specifies the session to which the control code applies.

[in] dwCtlCode

Specifies a value (a control code) that identifies the operation to perform.

Currently, MGMCTL_SETAGENTPORT is the only supported control code. Setting this code allows an SNMP management application to send requests to a remote agent that is "listening" for SNMP manager requests on an arbitrary port. For more information, see the lpvInBuffer and the cbInBuffer parameter descriptions.

[in] lpvInBuffer

Pointer to the buffer that contains the input parameters required for the operation.

When you specify the MGMCTL_SETAGENTPORT control code, this parameter must point to an unsigned integer that specifies the port number on which the remote agent will "listen" for SNMP manager requests. The port number must be in host-byte order.

[in] cbInBuffer

Specifies the size, in bytes, of the buffer pointed to by the lpvInBuffer parameter.

When you specify the MGMCTL_SETAGENTPORT control code, this parameter is equal to sizeof(UINT).

[out] lpvOUTBuffer

Pointer to the buffer that receives the operation's output data.

[out] cbOUTBuffer

Specifies the size, in bytes, of the buffer pointed to by the lpvOutBuffer parameter.

[out] lpcbBytesReturned

Pointer to a variable that receives the actual size, in bytes, of the data stored in the buffer pointed to by the lpvOutBuffer parameter.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError can also return one of the following error codes.

Return code Description
SNMP_MGMTAPI_INVALID_CTL
The dwCtlCode parameter does not specify a valid control code.
SNMP_MGMTAPI_INVALID_SESSION
The session parameter does not specify a valid SNMP session.
SNMP_MGMTAPI_INVALID_BUFFER
One or more of the lpvInBuffer, lpvOutBuffer, or lpcbBytesRequired parameters are invalid, or the cbInBuffer or cbOutBuffer parameter is too small.

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 mgmtapi.h
Library Mgmtapi.lib
DLL Mgmtapi.dll

See also

SNMP Functions

Simple Network Management Protocol (SNMP) Overview

SnmpMgrOpen