Amitabh Shukla wrote: > Thanks everyone for your responses. Like I mentioned in my original > post, I was looking for some APIs to get the ports and the > corresponding processes "programatically". I am not inclined to use > netstat or lsof for two reasons: > > 1. External program. May not be available. Hence cannot depend on it. > 2. External program. Don't want to spawn a process. > > It seems that there is no easily available documentation for doing > this especially on Windows. There has to be a way which is why netstat > , Openfiles and PortQuery work. But I was not able to lay my hands on > any document for that (or some sample code).
Did you bother to check out the URL in my last post? 90% of the APIs used by netstat to get the information you are after are completely undocumented. > I will continue to search for it. Else I'll start to think of the > external utilities or some workarounds for my requirements. 'netstat' is pretty much a program available everywhere. 'lsof', not so much. You can assume that if there is network connectivity that 'netstat' exists. I understand the desire to avoid running an external program but, in this case, you will find the reward bittersweet. Very little to be gained. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
