【正文】
屏幕監(jiān)控。其中屏幕監(jiān)控屬于擴展功能用于日后完善,網(wǎng)絡(luò)監(jiān)控是該系統(tǒng)的重點:實現(xiàn)包括獲取遠程計算機的網(wǎng)絡(luò)狀態(tài)(TCP、UDP) ,獲?。↖P、TCP 、UDP)統(tǒng)計數(shù)據(jù)信息,刪除網(wǎng)絡(luò)連接表中的連接條,關(guān)聯(lián)進程通過端口關(guān)聯(lián)打開此端口的進程信息。第三,命令:查看進程、查看服務(wù)、遠程關(guān)機、消息傳遞。用于獲取遠程計算機的所有運行進程、服務(wù)等。 主要子模塊設(shè)計實現(xiàn)1.鏈接建立與用戶驗證模塊該模塊默認的遠程 IP 地址為 ,用戶名:admin,用戶密碼:admin 如圖所示圖 44 遠程連接模塊客戶端安裝時向注冊表中寫入系統(tǒng)用戶,驗證模塊通過輸入簡單的用戶名進行驗證。方法如下: 39??蛻舳藢懭胱员淼南到y(tǒng)用戶,默認為:用戶名 admin,密碼 admin SaveSetting(MYAPP, USER, USER, admin) SaveSetting(MYAPP, USER, PASSWORD, admin)39。用戶驗證方法 If = GetSetting(MYAPP, USER, USER) And = GetSetting(MYAPP, USER, PASSWORD) Then = True () Else (用戶名或密碼錯誤, 遠程計算機網(wǎng)絡(luò)管理系統(tǒng)[客戶端], , ) = = () End If2.網(wǎng)絡(luò)監(jiān)控模塊功能實現(xiàn)該功能模塊主要作用:顯示服務(wù)器端的網(wǎng)絡(luò)鏈接狀態(tài),服務(wù)器端通信的 TCP、UDP、IP統(tǒng)計數(shù)據(jù)表,端口關(guān)聯(lián)進程信息。如圖 45 所示:圖 45 網(wǎng)絡(luò)監(jiān)控模塊1 使用到的控件主要包括:ListView、ContextMenuStrip其中 ListView 中 view 設(shè)置為 detail,columns 增加六個 ColumnHeader 成員,其中 text 分別為:遠程 IP 地址、遠程端口、本地 IP 地址、本地端口、通信狀態(tài)、通信協(xié)議。增加三個ContextMenuStrip用于建立右鍵菜單。其中包括: TCP數(shù)據(jù)統(tǒng)計、IP數(shù)據(jù)統(tǒng)計、UDP數(shù)據(jù)統(tǒng)計。并且跟ListView中的contextMenuStrip屬性相關(guān)聯(lián)。實現(xiàn)單擊右鍵顯示右鍵菜單方法如下: Private Sub ContextMenuStrip1_MouseUp(ByVal sender As Object, ByVal e As ) Handles If = Then (Me, , ) End IfEnd Sub2 數(shù)據(jù)處理①由于接收到的消息中的 TCP 連接的狀態(tài)為數(shù)字表示,需要轉(zhuǎn)換成直觀的文字,所以必須定義部分常量用于表示此些狀態(tài): Private Const MIB_TCP_STATE_CLOSED As Short = 1 Private Const MIB_TCP_STATE_LISTEN As Short = 2 Private Const MIB_TCP_STATE_SYN_SENT As Short = 3 Private Const MIB_TCP_STATE_SYN_RCVD As Short = 4 Private Const MIB_TCP_STATE_ESTAB As Short = 5 Private Const MIB_TCP_STATE_FIN_WAIT1 As Short = 6 Private Const MIB_TCP_STATE_FIN_WAIT2 As Short = 7 Private Const MIB_TCP_STATE_CLOSE_WAIT As Short = 8 Private Const MIB_TCP_STATE_CLOSING As Short = 9 Private Const MIB_TCP_STATE_LAST_ACK As Short = 10 Private Const MIB_TCP_STATE_TIME_WAIT As Short = 11 Private Const MIB_TCP_STATE_DELETE_TCB As Short = 12②端口號轉(zhuǎn)換該客戶端獲取的信息是服務(wù)器端執(zhí)行命令的直接結(jié)果,所以客戶端獲取的端口號為服務(wù)器端調(diào)用 API 函數(shù)獲取的端口號,該號是以二進制代碼表示,所以必須轉(zhuǎn)換成直觀的 10 進制數(shù)。方法如下:Private Function GetTcpPortNumber(ByRef DWord As Integer) As Integer GetTcpPortNumber = DWord / 256 + (DWord Mod 256) * 256 End Function③IP 地址轉(zhuǎn)換該方法是將整數(shù)型的 IP 地址轉(zhuǎn)換成字符串的形式,方法如下:Private Function GetIpFromLong(ByRef lngIPAddress As Integer) As String Dim arrIpParts() As Byte = (lngIPAddress) GetIpFromLong = CStr(arrIpParts(0)) amp。 . amp。 CStr(arrIpParts(1)) amp。 . amp。 CStr(arrIpParts(2)) amp。 . amp。 CStr(arrIpParts(3)) End Function④舉例表示 TCP 統(tǒng)計數(shù)據(jù)類實現(xiàn)該類包括類成員和方法等,方法如下:Class TCP Private Shared m_MinimumTimeout As Integer = 1 Private Shared m_MaximumTimeout As Integer = 1 Private Shared m_MaximumConnections As Integer = 1 Private Shared m_ActiveOpens As Integer = 1 Private Shared m_PassiveOpens As Integer = 1 Private Shared m_AttemptFails As Integer = 1 Private Shared m_EstabResets As Integer = 1 Private Shared m_CurrEstab As Integer = 1 Private Shared m_InSegments As Integer = 1 Private Shared m_OutSegments As Integer = 1 Private Shared m_RetransSegments As Integer = 1 Private Shared m_InErrors As Integer = 1 Private Shared m_OutResets As Integer = 1 Private Shared m_CumulativeConnections As Integer = 1 Private Shared m_Algorithm As String = Nothing Private Shared m_LastError As String = Nothing ReadOnly Property LastError() As String Get Return m_LastError End Get End Property ReadOnly Property MaxRetransmissionTimeOut() As Integer Get Return m_MaximumTimeout End Get End Property ReadOnly Property MinRetransmissionTimeout() As Integer Get Return m_MinimumTimeout End Get End Property ReadOnly Property RTO() As String Get Return m_Algorithm End Get End Property ReadOnly Property CumulativeConnections() As Integer Get Return m_CumulativeConnections End Get End Property ReadOnly Property SegmentsOutReset() As Integer Get Return m_OutResets End Get End Property ReadOnly Property ErrorsIn() As Integer Get Return m_InErrors End Get End Property ReadOnly Property RetransmittedSegments() As Integer Get Return m_RetransSegments End Get End Property ReadOnly Property SegmentsOut() As Integer Get Return m_OutSegments End Get End Property ReadOnly Property SegmentsIn() As Integer Get Return m_InSegments End Get End Property ReadOnly Property ConnectionCount() As Integer Get Return m_CurrEstab End Get End Property ReadOnly Property MinimumTimeout() As Integer Get Return m_MinimumTimeout End Get End Property ReadOnly Property MaximumTimeout() As Integer Get Return m_MaximumTimeout End Get End Property ReadOnly Property MaximumConnections() As Integer Get Return m_MaximumConnections End Get End Property ReadOnly Property ActiveOpens() As Integer Get Return m_ActiveOpens End Get End Property ReadOnly Property PassiveOpens() As Integer Get Return m_PassiveOpens