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
2010-10-10 23:21:19
Will try that and get back with the results. Thanks.
Ronaldo Junior
2010-10-10 23:40:12
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
2010-10-11 00:44:51
@Ronaldo, check this link http://smeschini.altervista.org/download/netstat32.php for a sample application using the GetTcpTable.
RRUZ
2010-10-11 00:59:30
Thanks a lot - exactly what I was looking for.
Ronaldo Junior
2010-10-11 03:38:12
+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
2010-10-11 06:06:27
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
2010-10-15 02:43:34