[VB.Net] Local/Remote TCP info from process [Source] - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19) +---- Thread: [VB.Net] Local/Remote TCP info from process [Source] (/showthread.php?tid=19298) |
[VB.Net] Local/Remote TCP info from process [Source] - The-One - 06-04-2011 Hey, I never really intended to release it as I had some crap with this getting it to work. Though I had lots of help with this since I liked it more then WireShark and I got all the info I needed without searching. I've used this for packet logging of: HWID applications, games and other things you will find out while using this. Screenshot: We are going to use iphlpapi.dll (GetExtendedTcpTable) to get the information. First, declare the API and some structures we need: Code: <DllImport("iphlpapi.dll", SetLastError:=True)> _ Now comes the most important function of this, the part where we get all the connections. Code: Private Function GetAllTcpConnections() As tcprows() As I'm using a Command Application I made this: Code: Public Sub CheckProcess_Tcp(ByVal procname As String) This will check if a row in the table contains the matched ID of the process we are looking for. As you see there are some errors. We need to translate the port and IP. Code: Private Function tPort(ByVal port As Integer) As Integer Enjoy, any questions can be asked below. I'd appreciate if you reply below RE: [VB.Net] Local/Remote TCP info from process [Source] - goranpilkic - 06-04-2011 I created something same long time ago. Only think mine was getting all ip's. Nice.. RE: [VB.Net] Local/Remote TCP info from process [Source] - The-One - 06-04-2011 (06-04-2011, 01:17 PM)goranpilkic Wrote: I created something same long time ago. No problem, thanks for the first response and rate. RE: [VB.Net] Local/Remote TCP info from process [Source] - superfreak3 - 07-06-2012 I hope someone is still monitoring this thread. I'm trying to get a process name if a port is found to be in use. I'm hoping someone can help me leverage the information here to get the job done. My current code (installer custom action) works to detect if the port is in use, but I want to take it a step further and get the process name of the port user. If is a certain value I will allow the use of that port in the install dialog. If not, I will notify that port is in use. Anyway, here's my code... Code: Dim hostname As String = "127.0.0.1" Like I said, this code works pretty well or so it seems. I just want to add a layer to it to check the process by PID I guess, grab the name and if = to or contains "MyValue" then allow the in use port to be selected or used during the install. I hope someone can help. RE: [VB.Net] Local/Remote TCP info from process [Source] - Business.Gov - 07-06-2012 Looks pretty nice. Do you plan on ever switching it into a windows form instead of console? RE: [VB.Net] Local/Remote TCP info from process [Source] - Kenneth - 08-11-2012 Awesome, thanks for sharing. c: |