The source code is as follows:
CMibBrowserView: : OnGet ()
{
HTREEITEM hNode; MibNode * pNodeData;
Cstrings ipadd, community, oidstr; M_ipadd. GetWindowText (ipadd); If (m_ipadd IsBlank ())
{
AfxMessageBox (" IP address wrong!" ); return ;
}
M_ipadd. GetWindowText (ipadd); M_community. GetWindowText (community); M_oid. GetWindowText (oidstr); Ipadd +=": 161";
Snmp: : socket_startup ();
UdpAddress address (LPCTSTR ipadd); Oid Oid (LPCTSTR oidstr); Snmp_version version=version1.
Int the status;
Snmp Snmp (status, 0, false); Pdu Pdu.
Vb Vb; Vb. Set_oid (oid); Pdu +=vb;
CTarget CTarget (address); Ctarget. Set_version (version); Ctarget. Set_retry (1); Ctarget. Set_timeout (100);
Ctarget. Set_readcommunity ((LPCTSTR) community); SnmpTarget * target;
Target=& amp; Ctarget;
Status=SNMP. Get (pdu, * target);
If (status==SNMP_CLASS_SUCCESS)
{
Pdu. Get_vb (vb, 0);
Cstrings reply_oid=vb. Get_printable_oid (); Cstrings reply_value=https://bbs.csdn.net/topics/vb.get_printable_value (); HNode=SearchNode (reply_oid);
If (hNode!=NULL)
{
pNodeData=https://bbs.csdn.net/topics/(MibNode *) m_tree. GetItemData (hNode); Reply_oid. Replace ((LPCTSTR) pNodeData -> poids,
(LPCTSTR) m_tree. GetItemText (hNode)); If (pNodeData - & gt; PInteger!=NULL)
{
The POSITION index=pNodeData - & gt; PInteger - & gt; Find (reply_value); If (index!=NULL)
{
PNodeData - & gt; PInteger - & gt; GetNext (index); reply_value=https://bbs.csdn.net/topics/pNodeData-> PInteger -> GetNext (index);
}
}
}
If (m_list GetItemCount () & gt; 0) m_list. DeleteAllItems ();
Int row=m_list. InsertItem (1, reply_oid); M_list. SetItemText (row 1, reply_value);
}
Snmp: : socket_cleanup ();
CMainFrame * pF=(CMainFrame *) AfxGetMainWnd (); Int num=m_list. GetItemCount (); Oidstr. The Format (" % d ", num);
Oidstr="altogether retrieve" + oidstr + "object"; PF - & gt; M_wndStatusBar. SetPaneText (0, oidstr);
}