📄 details.htm
字号:
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
</HEAD>
<BODY>
<FONT color="#008000" size="2">
<P>
// View.cpp : implementation of the CWinNetStatView class
</P>
<P>
//
</P>
<P>
</FONT><FONT color="#0000ff" size="2">#include</FONT><FONT size="2"> "stdafx.h"</P>
<P>
</FONT><FONT color="#0000ff" size="2">#include</FONT><FONT size="2"> "WinNetStat.h"</P>
<P>
</FONT><FONT color="#0000ff" size="2">#include</FONT><FONT size="2"> "WinNetStatDoc.h"</P>
<P>
</FONT><FONT color="#0000ff" size="2">#include</FONT><FONT size="2"> "WinNetStatView.h"</P>
<P>
</FONT><FONT color="#0000ff" size="2">#include</FONT><FONT size="2"> "netstatmanager.h"</P>
<P>
</FONT><FONT color="#0000ff" size="2">#ifdef</FONT><FONT size="2"> _DEBUG</P>
<P>
</FONT><FONT color="#0000ff" size="2">#define</FONT><FONT size="2"> </FONT><FONT color="#0000ff" size="2">
new</FONT><FONT size="2"> DEBUG_NEW</P>
<P>
</FONT><FONT color="#0000ff" size="2">#endif</P>
<P>
</FONT><FONT color="#008000" size="2"> </P>
<P>
// CWinNetStatView
</P>
<P>
</FONT><FONT size="2">IMPLEMENT_DYNCREATE(CWinNetStatView, CFormView)</P>
<P>
BEGIN_MESSAGE_MAP(CWinNetStatView, CFormView)
</P>
<P>
ON_BN_CLICKED(IDC_TCPSTATS, OnClickedTcpstats)
</P>
<P>
ON_BN_CLICKED(IDC_UDPTATS, OnBnClickedUdptats)
</P>
<P>
ON_BN_CLICKED(IDC_IPSTATS, OnBnClickedIpstats)
</P>
<P>
ON_BN_CLICKED(IDC_NW_PARAMS, OnBnClickedNwParams)
</P>
<P>
ON_BN_CLICKED(IDC_ADAPTER_INFO, OnBnClickedAdapterInfo)
</P>
<P>
END_MESSAGE_MAP()
</P>
<P>
</FONT><FONT color="#008000" size="2"> </P>
<P>
// CWinNetStatView construction/destruction
</P>
<P>
</FONT><FONT size="2">CWinNetStatView::CWinNetStatView()</P>
<P>
: CFormView(CWinNetStatView::IDD)
</P>
<P>
{
</P>
<P>
</FONT><FONT color="#008000" size="2">// TODO: add construction code here</P>
<P>
</FONT><FONT size="2">}</P>
<P>
CWinNetStatView::~CWinNetStatView()
</P>
<P>
{
</P>
<P>
}
</P>
<P>
</FONT><FONT color="#0000ff" size="2">void</FONT><FONT size="2"> CWinNetStatView::DoDataExchange(CDataExchange*
pDX)</P>
<P>
{
</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
CFormView::DoDataExchange(pDX);
</P>
<P>
DDX_Control(pDX, IDC_TEXT_OUTPUT, m_TextOutput);
</P>
</BLOCKQUOTE>
<P>
}
</P>
<P>
BOOL CWinNetStatView::PreCreateWindow(CREATESTRUCT& cs)
</P>
<P>
{
</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P></FONT><FONT color="#008000" size="2">// TODO: Modify the Window class
or styles here by modifying</P>
<P>
</FONT><FONT color="#008000" size="2">// the CREATESTRUCT cs</P>
<P>
</FONT><FONT color="#0000ff" size="2">return</FONT><FONT size="2"> CFormView::PreCreateWindow(cs);</P></BLOCKQUOTE>
<P>
}
</P>
<P>
</FONT><FONT color="#0000ff" size="2"> </P>
<P>
void</FONT><FONT size="2"> CWinNetStatView::OnInitialUpdate()</P>
<P>
{
</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
CFormView::OnInitialUpdate();
</P>
<P>
GetParentFrame()->RecalcLayout();
</P>
<P>
ResizeParentToFit();
</P>
</BLOCKQUOTE>
<P>
}
</P>
<P>
</FONT><FONT color="#008000" size="2"> </P>
<P>
// CWinNetStatView diagnostics
</P>
<P>
</FONT><FONT color="#0000ff" size="2">#ifdef</FONT><FONT size="2"> _DEBUG</P>
<P>
</FONT><FONT color="#0000ff" size="2">void</FONT><FONT size="2"> CWinNetStatView::AssertValid()
</FONT><FONT color="#0000ff" size="2">const</P>
<P>
</FONT><FONT size="2">{</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
CFormView::AssertValid();
</P>
</BLOCKQUOTE>
<P>
}
</P>
<P>
</FONT><FONT color="#0000ff" size="2"> </P>
<P>
void</FONT><FONT size="2"> CWinNetStatView::Dump(CDumpContext& dc) </FONT>
<FONT color="#0000ff" size="2">const</P>
<P>
</FONT><FONT size="2">{</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
CFormView::Dump(dc);
</P>
</BLOCKQUOTE>
<P>
}
</P>
<P>
CWinNetStatDoc* CWinNetStatView::GetDocument() </FONT><FONT color="#0000ff" size="2">
const</FONT><FONT size="2"> </FONT><FONT color="#008000" size="2">// non-debug
version is inline</P>
<P>
</FONT><FONT size="2">{</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWinNetStatDoc)));
</P>
<P></FONT><FONT color="#0000ff" size="2">return</FONT><FONT size="2"> (CWinNetStatDoc*)m_pDocument;</P></BLOCKQUOTE>
<P>
}
</P>
<P>
</FONT><FONT color="#0000ff" size="2"> </P>
<P>
#endif</FONT><FONT size="2"> </FONT><FONT color="#008000" size="2">//_DEBUG</P>
<P>
// CWinNetStatView message handlers
</P>
<P>
</FONT><FONT color="#0000ff" size="2">void</FONT><FONT size="2"> CWinNetStatView::OnClickedTcpstats()</P>
<P>
{
</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P></FONT><FONT color="#008000" size="2">//CNetStatManager statMgr; //
TODO: Add your control notification handler code here</P>
<P>
</FONT><FONT size="2">MIB_TCPSTATS TcpStatsMIB;</P>
<P>
<FONT color="#0000cc"><STRONG>::GetTcpStatistics(&TcpStatsMIB);</STRONG></FONT>
</P>
<P>
CString strMsg;
</P>
<P>
CString strOutPut;
</P>
<P>
strOutPut.Format("\r\n************************************\r\n");
</P>
<P>
strMsg.Format("\tTCP/IP Statistics\t\r\n");
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("\r\n************************************\r\n");
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("time-out algorithm:\t%d\r\n",TcpStatsMIB.dwRtoAlgorithm);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("minimum time-out:\t%d\r\n",TcpStatsMIB.dwRtoMin);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("maximum time-out:\t%d\r\n",TcpStatsMIB.dwRtoMax);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("maximum connections:\t%d\r\n",TcpStatsMIB.dwMaxConn);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("active opens:\t%d\r\n",TcpStatsMIB.dwActiveOpens);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("passive opens:\t%d\r\n",TcpStatsMIB.dwPassiveOpens);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("failed attempts:\t%d\r\n",TcpStatsMIB.dwAttemptFails);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("established connections
reset:\t%d\r\n",TcpStatsMIB.dwEstabResets);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("established connections:\t%d\r\n",TcpStatsMIB.dwCurrEstab);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("segments received:\t%d\r\n",TcpStatsMIB.dwInSegs);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("segment sent:\t%d\r\n",TcpStatsMIB.dwOutSegs);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("segments retransmitted:\t%d\r\n",TcpStatsMIB.dwRetransSegs);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("incoming errors:\t%d\r\n",TcpStatsMIB.dwInErrs);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("outgoing resets:\t%d\r\n",TcpStatsMIB.dwOutRsts);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("cumulative connections:\t%d\r\n",TcpStatsMIB.dwNumConns);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
m_TextOutput.SetWindowText(strOutPut);
</P>
</BLOCKQUOTE>
<P>
}
</P>
<P>
</FONT><FONT color="#0000ff" size="2"> </P>
<P>
void</FONT><FONT size="2"> CWinNetStatView::OnBnClickedUdptats()</P>
<P>
{
</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P></FONT><FONT color="#008000" size="2">//CNetStatManager statMgr; //
TODO: Add your control notification handler code here</P>
<P>
</FONT><FONT size="2">MIB_UDPSTATS UDPStatsMIB;</P>
<P>
<STRONG><FONT color="#0000cc">::GetUdpStatistics(&UDPStatsMIB);</FONT></STRONG>
</P>
<P>
CString strMsg;
</P>
<P>
CString strOutPut;
</P>
<P>
strOutPut.Format("\r\n************************************\r\n");
</P>
<P>
strMsg.Format("\tUDP Statistics\t\r\n");
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("\r\n************************************\r\n");
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("received datagrams:\t%d\r\n",UDPStatsMIB.dwInDatagrams);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("datagrams for which no port
exists:\t%d\r\n",UDPStatsMIB.dwNoPorts);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("errors on received datagrams:\t%d\r\n",UDPStatsMIB.dwInErrors);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("sent datagrams:\t%d\r\n",UDPStatsMIB.dwOutDatagrams);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
strMsg.Format("number of entries in UDP listener
table:\t%d\r\n",UDPStatsMIB.dwNumAddrs);
</P>
<P>
strOutPut+=strMsg;
</P>
<P>
m_TextOutput.SetWindowText(strOutPut);
</P>
</BLOCKQUOTE>
<P>
}
</P>
<P>
</FONT><FONT color="#0000ff" size="2"> </P>
<P>
void</FONT><FONT size="2"> CWinNetStatView::OnBnClickedIpstats()</P>
<P>
{
</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P></FONT><FONT color="#008000" size="2">// CNetStatManager statMgr; //
TODO: Add your control notification handler code here</P></FONT><FONT size="2">
<P>
MIB_IPSTATS IPStatsMIB;
</P>
<P>
<FONT color="#0000cc"><STRONG>::GetIpStatistics(&IPStatsMIB);</STRONG></FONT>
</P>
<P>
CString strMsg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -