我是mynull,没人解答自己弄出来了,回收分!
另外版主查查,有多少人是像楼上那样被CSDN的所谓规则培养出来的Imports System.DiagnosticsPublic Class moviePorts
Public Structure moviePortDefine
Dim TCP_port As Integer
Dim GroupID As Integer
Dim GroupName As String
Dim Cnt As Integer
End Structure
public shared Sub main()
Dim NP(1) As moviePortDefine
NP(0).TCP_port = 554
NP(0).GroupID =1
NP(0).GroupName ="RealStream"
NP(0).TCP_port = 80
NP(0).GroupID =2
NP(0).GroupName ="Web"
getTCPclientNub(NP)
End Sub
Public Function getTCPclientNub(ByRef NowFindedPort() As moviePortDefine) As String
Dim p As New Process()
p.StartInfo.FileName = "netstat.exe"
p.StartInfo.Arguments = "-n"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.Start() Dim output As String = p.StandardOutput.ReadToEnd()
p.WaitForExit() Dim ss() As String = output.Split(vbCrLf)
Dim ssTcp() As String
Dim i, j, k As Long
For i = 0 To ss.GetUpperBound(0)
If InStr(1, ss(i), "ESTABLISHED", CompareMethod.Text) > 0 Then
k = InStr(ss(i), ":")
If k > 0 Then j = InStr(k + 1, ss(i), " ", 1)
If j > k Then
k = Val(Mid(ss(i), k + 1, j - k))
For j = 0 To NowFindedPort.GetUpperBound(0)
If k = NowFindedPort(j).TCP_port Then
NowFindedPort(j).Cnt += 1
Exit For
End If
Next
End If
End If
Next Return output
End Function
另外版主查查,有多少人是像楼上那样被CSDN的所谓规则培养出来的Imports System.DiagnosticsPublic Class moviePorts
Public Structure moviePortDefine
Dim TCP_port As Integer
Dim GroupID As Integer
Dim GroupName As String
Dim Cnt As Integer
End Structure
public shared Sub main()
Dim NP(1) As moviePortDefine
NP(0).TCP_port = 554
NP(0).GroupID =1
NP(0).GroupName ="RealStream"
NP(0).TCP_port = 80
NP(0).GroupID =2
NP(0).GroupName ="Web"
getTCPclientNub(NP)
End Sub
Public Function getTCPclientNub(ByRef NowFindedPort() As moviePortDefine) As String
Dim p As New Process()
p.StartInfo.FileName = "netstat.exe"
p.StartInfo.Arguments = "-n"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.Start() Dim output As String = p.StandardOutput.ReadToEnd()
p.WaitForExit() Dim ss() As String = output.Split(vbCrLf)
Dim ssTcp() As String
Dim i, j, k As Long
For i = 0 To ss.GetUpperBound(0)
If InStr(1, ss(i), "ESTABLISHED", CompareMethod.Text) > 0 Then
k = InStr(ss(i), ":")
If k > 0 Then j = InStr(k + 1, ss(i), " ", 1)
If j > k Then
k = Val(Mid(ss(i), k + 1, j - k))
For j = 0 To NowFindedPort.GetUpperBound(0)
If k = NowFindedPort(j).TCP_port Then
NowFindedPort(j).Cnt += 1
Exit For
End If
Next
End If
End If
Next Return output
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货