Lets assume you have a app that opens a socket port for communication purposes. How can I get the path of this app only by knowing its port?
I want to do what netstat -b does. It lists all socket ports opened and the app that opened the socket.
I am using delphi 2010.
By knowing which app opened which port I am able to kill the app.
Note that I need a delphi code, not an Dos command or an explanation of how to use netstat.
Rafael, you can use the
GetExtendedTcpTablefunction, this function retrieves a table that contains a list of TCP connections availables.first you must inspect the records returned by this function, and check the
dwLocalPortordwRemotePort(depending of what port your need to check), then you can get the pid of the application checking thedwOwningPidfield and resolve the exe name using a windows api function likeGetModuleFileNameExCheck this sample application which show all tcp connections like netstat. you can modify this sample to fit with your requirements.