J
Jm
Hi All
Ive asked this question in ms.public.dotnet.framework.interop but havent got
a reply so im hoping someone may be able to help here. I am a bit of a
newbie to vbnet and am having trouble using some code from
vb6 in vb.net. Im sure its pretty easy to convert but im just unsure of what
to do. This is the original code i would use
Public Type MIB_TCPROW
dwState As Long
dwLocalAddr As Long
dwLocalPort As Long
dwRemoteAddr As Long
dwRemotePort As Long
End Type
Public Type MIB_TCPTABLE
dwNumEntries As Long
table(100) As MIB_TCPROW
End Type
Public MIB_TCPTABLE As MIB_TCPTABLE
Public Declare Function GetTcpTable Lib "iphlpapi.dll" (ByRef pTcpTable As
MIB_TCPTABLE, ByRef pdwSize As Long, ByVal bOrder As Long) As Long
Public Declare Function SetTcpEntry Lib "IPhlpAPI" (pTcpRow As MIB_TCPROW)
As Long
Public Declare Function ntohs Lib "WSOCK32.DLL" (ByVal netshort As Long) As
Long
Public Sub BlockPort(Port As String)
' Port Blocking Function
Dim LTmp As Long
Dim x As Integer, i As Integer, n As Integer
Dim RemP As String
Dim tcpt As MIB_TCPTABLE
LTmp = Len(MIB_TCPTABLE)
GetTcpTable tcpt, LTmp, 0
x = tcpt.dwNumEntries
For i = 0 To tcpt.dwNumEntries - 1
RemP = ntohs(tcpt.table(i).dwRemotePort)
If RemP = Port And tcpt.table(i).dwState <> 2 Then
tcpt.table(i).dwState = 12
SetTcpEntry tcpt.table(i)
End If
Next i
End Sub
From what ive learned so far types arent allowed as they were in vb6 and i
should be using structures now. But im unsure if i need to change anything
else. The code under vb6 was used on a timer to block tcp traffic on a
specified port. Is it possible to convert this code to be used in vb.net ?
Any help is greatly appreciated
Thanks
Ive asked this question in ms.public.dotnet.framework.interop but havent got
a reply so im hoping someone may be able to help here. I am a bit of a
newbie to vbnet and am having trouble using some code from
vb6 in vb.net. Im sure its pretty easy to convert but im just unsure of what
to do. This is the original code i would use
Public Type MIB_TCPROW
dwState As Long
dwLocalAddr As Long
dwLocalPort As Long
dwRemoteAddr As Long
dwRemotePort As Long
End Type
Public Type MIB_TCPTABLE
dwNumEntries As Long
table(100) As MIB_TCPROW
End Type
Public MIB_TCPTABLE As MIB_TCPTABLE
Public Declare Function GetTcpTable Lib "iphlpapi.dll" (ByRef pTcpTable As
MIB_TCPTABLE, ByRef pdwSize As Long, ByVal bOrder As Long) As Long
Public Declare Function SetTcpEntry Lib "IPhlpAPI" (pTcpRow As MIB_TCPROW)
As Long
Public Declare Function ntohs Lib "WSOCK32.DLL" (ByVal netshort As Long) As
Long
Public Sub BlockPort(Port As String)
' Port Blocking Function
Dim LTmp As Long
Dim x As Integer, i As Integer, n As Integer
Dim RemP As String
Dim tcpt As MIB_TCPTABLE
LTmp = Len(MIB_TCPTABLE)
GetTcpTable tcpt, LTmp, 0
x = tcpt.dwNumEntries
For i = 0 To tcpt.dwNumEntries - 1
RemP = ntohs(tcpt.table(i).dwRemotePort)
If RemP = Port And tcpt.table(i).dwState <> 2 Then
tcpt.table(i).dwState = 12
SetTcpEntry tcpt.table(i)
End If
Next i
End Sub
From what ive learned so far types arent allowed as they were in vb6 and i
should be using structures now. But im unsure if i need to change anything
else. The code under vb6 was used on a timer to block tcp traffic on a
specified port. Is it possible to convert this code to be used in vb.net ?
Any help is greatly appreciated
Thanks