- #include "IPHlpApi.h"
- #pragma comment(lib,"IPHLPAPI.LIB")
- #pragma comment(lib,"netapi32.lib ")
- void CGkbc8Dlg::OnButton2()
- {
- CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
- pListBox->ResetContent();
- MIB_TCPSTATS TCPStats;
- //获得TCP协议统计信息
- if (GetTcpStatistics(&TCPStats) != NO_ERROR)
- {
- return;
- }
- CString strText = _T("");
- strText.Format(_T("time-out algorithm:%d"),
- TCPStats.dwRtoAlgorithm);
- pListBox->AddString(strText);
- strText.Format(_T("minimum time-out:%d"),
- TCPStats.dwRtoMin);
- pListBox->AddString(strText);
- strText.Format(_T("maximum time-out:%d"),
- TCPStats.dwRtoMax);
- pListBox->AddString(strText);
- strText.Format(_T("maximum connections:%d"),
- TCPStats.dwMaxConn);
- pListBox->AddString(strText);
- strText.Format(_T("active opens:%d"),
- TCPStats.dwActiveOpens);
- pListBox->AddString(strText);
- strText.Format(_T("passive opens:%d"),
- TCPStats.dwPassiveOpens);
- pListBox->AddString(strText);
- strText.Format(_T("failed attempts:%d"),
- TCPStats.dwAttemptFails);
- pListBox->AddString(strText);
- strText.Format(_T("established connections reset:%d"),
- TCPStats.dwEstabResets);
- pListBox->AddString(strText);
- strText.Format(_T("established connections:%d"),
- TCPStats.dwCurrEstab);
- pListBox->AddString(strText);
- strText.Format(_T("segments received:%d"),
- TCPStats.dwInSegs);
- pListBox->AddString(strText);
- strText.Format(_T("segment sent:%d"),
- TCPStats.dwOutSegs);
- pListBox->AddString(strText);
- strText.Format(_T("segments retransmitted:%d"),
- TCPStats.dwRetransSegs);
- pListBox->AddString(strText);
- strText.Format(_T("incoming errors:%d"),
- TCPStats.dwInErrs);
- pListBox->AddString(strText);
- strText.Format(_T("outgoing resets:%d"),
- TCPStats.dwOutRsts);
- pListBox->AddString(strText);
- strText.Format(_T("cumulative connections:%d"),
- TCPStats.dwNumConns);
- pListBox->AddString(strText);
- }
复制代码
如上面的按钮点击代码。点击后会在列表控件中显示出信息。
IDC_LIST1为我们添加的列表框控件ID:CListBox;
上位机MFC如何获得本地计算机的TCP协议统计信息
上位机VC MFC程序开发精典实例大全源码与视频讲解配套下载408例 经历1年的编程与录制点击进入查看
如果您认可,可联系功能定制! 如果您着急,充值会员可直接联系发您资料!
|