views:

95

answers:

1

I need to deal with the result of a command line like this: netstat -aon in Delphi, parse it and get to know all the ports already in use. Is there a library or component around that does that?

+4  A: 

To get this info you can use these WinAPi functions

Wich are located in the Iphlpapi.dll (Windows Api IP Helper) library.

for a delphi translation of these functions you can check the JwaIpHlpApi unit wich is part of the JEDI API Library

RRUZ
Will try that and get back with the results. Thanks.
Ronaldo Junior
Hi there - is there anything wrong (or even everything) with the code I'm using:var pTable: PMIB_TCPTABLE;begin size := 100000; // ????? GetTcpTable(pTable, size, True);The result is a huge number on the first field of pTable and only one entry on the second field, which is another record.
Ronaldo Junior
@Ronaldo, check this link http://smeschini.altervista.org/download/netstat32.php for a sample application using the GetTcpTable.
RRUZ
Thanks a lot - exactly what I was looking for.
Ronaldo Junior
+1 for mentioning Jedi Api Lib, better to use existing header translations than everybody doing their own!btw: we also keep a blog http://blog.delphi-jedi.net/ and the main page for Jwa is http://blog.delphi-jedi.net/jedi-api-headers/
Remko
In Windows vista and later, AllocateAndGetTcpExTableFromStackAllocateAndGetUdpExTableFromStack are deprecated. You should use [GetExtendedUdpTable][1] and [GetExtendedTcpTable][2] instead. [1] http://msdn.microsoft.com/en-us/library/aa365930%28v=VS.85%29.aspx [2] http://msdn.microsoft.com/en-us/library/aa365928%28v=VS.85%29.aspx
jachguate