How do I find out what process opened what port?
I want a method of finding out what process opened what port without the aid of an external application. I.e. no netstat or other tools like 开发者_如何学Pythonit.
You need to use the IP helper functions. More specifically GetExtendedTcpTable and GetExtendedUdpTable.
For example, for GetExtendedUdpTable, you can pass in MIB_UDPTABLE_OWNER_PID as the TableClass and you will be able to receive the PID of the process that issued the call to bind for the UDP endpoint.
精彩评论