[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Get the name of a window related to a network connection

Posted on 2003-03-15
8
Medium Priority
?
290 Views
Last Modified: 2011-04-14
In delphi, is there any way to enumerate all network connections currently active and find out what window/process they were created from. Thanks in advance.
0
Comment
Question by:ippopotimus
7 Comments
 
LVL 2

Expert Comment

by:steve_hsk
ID: 8146079
Hi ippopotimus ...

The short answer is of course YES (but I only know for XP) :-O ...

Stage One : Retreiving the list of Active Connections (NetStat through code) :
I'm not being lazy here, but I've just answered another question that asked how to do this ...
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20552007.html

Stage Two : Associating this data with the process using it :
If you are doing this for XP, this is relatively easy, using the undocumented IPHlpAPI function - AllocateAndGettcpExTableFromStack

The following site provides a simple example in C (sorry - haven't had the time to convert this to Delphi yet) that demonstrates listing the active connections and associating their Process IDs (PID)s
http://www.vbcity.com/forums/topic.asp?tid=8785

A tutorial explaining this method :
http://www.pcquest.com/content/coding/102082103.asp

A genral IPHlpAPI delphi site (in french) ... but good code example ...
http://iglooduhack.free.fr/delphi_ip_helper.php

For NT4 and 2000, I'm convinced that this is available in the MIB, but I can't find it at all !!!

The only other idea was to interface with the NDIS drivers and retrieve the PID vs Socket bindings.

I'll keep looking however ... This is actually an old project of mine that I never completed for NT4/2000 !!!

Hope this gets you started,
STeve

0
 
LVL 2

Expert Comment

by:steve_hsk
ID: 8146114
As an extra, I know this is possible on the 2000, NT4 platforms ... so dont give up ...

An excellant website (!) in general, but it has 2 utilities that list port Vs PID : TCPView.EXE and TDIMon.EXE :

http://www.sysinternals.com/ntw2k/utilities.shtml

STeve
0
 

Author Comment

by:ippopotimus
ID: 8146399
i really need this for windows 2000
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 4

Expert Comment

by:nestorua
ID: 8146965
HI,
Try WNetOpenEnum, WNetCloseEnum, WNetEnumResource functions.
Sincerely,
Nestorua.
0
 
LVL 2

Expert Comment

by:steve_hsk
ID: 8155024
Ipp ... I'm still trying ... your question has renewed my interest ... if you make any progress, let me know :-)

Nestorua ...

"The WNetCloseEnum function ends a network resource enumeration started by a call to the WNetOpenEnum function."

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetcloseenum.asp

From my understanding, this API set controls the actual network connection (RAS/LAN/WAN). I think (?) that Ipp wants to be able to list sockets that have active connections (IP/Port), owned by processes or apps.

I'm convinced that you can do this via the TDI Layer, using TDI_CONNECTION_INFO or TDI_CONNECTION_INFORMATION. Will keep working on it !

STeve
0
 

Expert Comment

by:CleanupPing
ID: 9316757
ippopotimus:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10639938
PAQed, with points refunded (490)

modulo
Community Support Moderator
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question