SnmpMgrClose
SnmpMgrOpen
SnmpMgrRequest能达到从某机器requestType中的三个操作就可以了.
-----------------------------------------------------另外indy组件能不能实现这些功能?

解决方案 »

  1.   

    Hoho你也要问问题哦?
    我找找,就msdn上有点。
    是api么?没看仔细
      

  2.   

    SnmpMgrCloseThe SnmpMgrClose function closes communications sockets and data structures associated with the specified session. This function is an element of the SNMP Management API.
    BOOL SnmpMgrClose(
      LPSNMP_MGR_SESSION session
    );Parameters
    session 
    [in] Pointer to an internal structure that specifies the session to close. For more information, see the following Res section. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. This function may return Windows Sockets error codes.Res
    Windows Server 2003:  SNMP manager applications can call SnmpMgrClose with a NULL session parameter to clean up resources associated with a successful call to the SnmpMgrTrapListen function. Note, however, that if your application is a DLL, it should not call SnmpMgrClose from its DllMain entry-point function.
    SnmpMgrClose must not be called when the application DLL is in the process of unloading.Windows Server 2003:  SnmpMgrClose takes longer to execute under Windows Server 2003 when compared to an identical call under Windows 2000. Specifically, a call to this API takes up to a second to execute under Windows Server 2003, whereas the same call takes around .3 milliseconds under Windows 2000. this may cause performance problems for Windows Server 2003 SNMP applications that call SnmpMgrOpen and SnmpMgrClose frequently. 
    To address this problem, create an extra SNMP manager session by calling SnmpMgrOpen on the localhost during application startup, and keep it open for the duration of the application's lifetime. Closing the session manager will close all associated sessions, requiring only one call to SnmpMgrClose..
    Requirements
    Client: Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation.
    Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
    Header: Declared in Mgmtapi.h.
    Library: Use Mgmtapi.lib.
      

  3.   

    SnmpMgrOpenThe SnmpMgrOpen function initializes communications sockets and data structures, allowing communications with the specified SNMP agent. This function is an element of the SNMP Management API.
    LPSNMP_MGR_SESSION SnmpMgrOpen(
      LPSTR lpAgentAddress,
      LPSTR lpAgentCommunity,
      INT nTimeOut,
      INT nRetries
    );Parameters
    lpAgentAddress 
    [in] Pointer to a null-terminated string specifying either a dotted-decimal IP address or a host name that can be resolved to an IP address, an IPX address (in 8.12 notation), or an ethernet address. 
    lpAgentCommunity 
    [in] Pointer to a null-terminated string specifying the SNMP community name used when communicating with the agent specified in the lpAgentAddress parameter. 
    nTimeOut 
    [in] Specifies the communications time-out in milliseconds. 
    nRetries 
    [in] Specifies the communications retry count. The time-out specified in the nTimeOut parameter is doubled each time a retry attempt is transmitted. 
    Return Values
    If the function succeeds, the return value is a pointer to an LPSNMP_MGR_SESSION structure. This structure is used internally and the programmer should not alter it. For more information, see the following Res section.If the function fails, the return value is NULL. To get extended error information, call GetLastError. GetLastError may return the SNMP_MEM_ALLOC_ERROR error code, which indicates a memory allocation error.This function may also return Windows Sockets error codes.The name and address of the SNMP target, or the string pointed to by the lpAgentAddress parameter, should conform to one of the following forms.Name/Address Form (example) 
    IP Address 157.57.8.160 
    IP Hostname merlin.microsoft.com 
    Ethernet Address 00aa00bbccdd 
    IPX Address 00006112.00aa00bbccdd Res
    Names can be provided for agents only if TCP/IP is loaded and the names are TCP/IP host names. NetBIOS names cannot be supplied for IPX hosts.Applications should not use the LPSNMP_MGR_SESSION pointer returned by this function to call the SnmpMgrRequest function in the context of a different thread.
      

  4.   

    SnmpMgrRequestThe SnmpMgrRequest function requests the specified operation be performed with the specified agent. This function is an element of the SNMP Management API.
    SNMPAPI SnmpMgrRequest(
      LPSNMP_MGR_SESSION session,
      BYTE requestType,
      SnmpVarBindList* variableBindings,
      AsnInteger* errorStatus,
      AsnInteger* errorIndex
    );Parameters
    session 
    [in] Pointer to an internal structure that specifies the session that will perform the request. 
    Applications should not specify the LPSNMP_MGR_SESSION pointer returned by this function in a different thread. You can specify a pointer returned by SnmpMgrOpen, but only if the calls to SnmpMgrOpen and SnmpMgrRequest originate in the context of the same thread.requestType 
    [in] Specifies the SNMP request type. This parameter can be one of the following values defined by SNMPv1. Value Meaning 
    SNMP_PDU_GET Retrieve the value or values of the specified variables. 
    SNMP_PDU_GETNEXT Retrieve the value or values of the lexicographic successor of the specified variable. 
    SNMP_PDU_SET Write a value within a specific variable. 
    Note that PDU request types have been renamed. For additional information, see SNMP Variable Types and Request PDU Types.
    variableBindings 
    [in, out] Pointer to the variable bindings list. 
    errorStatus 
    [out] Pointer to a variable in which the error status result will be returned. This parameter can be one of the following values defined by SNMPv1. Value Meaning 
    SNMP_ERRORSTATUS_NOERROR The agent reports that no errors occurred during transmission. 
    SNMP_ERRORSTATUS_TOOBIG The agent could not place the results of the requested operation into a single SNMP message. 
    SNMP_ERRORSTATUS_NOSUCHNAME The requested operation identified an unknown variable. 
    SNMP_ERRORSTATUS_BADVALUE The requested operation tried to change a variable but it specified either a syntax or value error. 
    SNMP_ERRORSTATUS_READONLY The requested operation tried to change a variable that was not allowed to change according to the community profile of the variable. 
    SNMP_ERRORSTATUS_GENERR An error other than one of those listed here occurred during the requested operation. errorIndex 
    [out] Pointer to a variable in which the error index result will be returned. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is NULL. To get extended error information, call GetLastError, which may return one of the following error codes.Return code Description 
    SNMP_MGMTAPI_TIMEOUT The request timed-out. 
    SNMP_MGMTAPI_SELECT_FDERRORS Unexpected error file descriptors indicated by the Windows Sockets select function. Res
    Retries and time-outs are supplied to the SnmpMgrOpen function. Each variable in the variable bindings list must be initialized to type ASN_NULL for Get and Get Next requests.
      

  5.   

    呵呵 楼上的全是MSND来的资料哦
      

  6.   

    先谢谢aiirii,我研究一下,还有上次那个问题一直没时间看...