Easily Identify Network Connections By Process In Your Windows Apps With This Excellent Component Suite
February 12, 2021 By Anbarasan
Sometimes Developers may need to monitor the network connections by process running in a machine programmatically. How to list down the network connections between local and remote address, ports , protocol, status etc. ? Don’t know how to do. Don’t worry. Для просмотра ссылки Войдиили Зарегистрируйся System Information Management Suite’s component helps to identify easily and we will learn how to use the thread TNetConMonThread to demonstrate the established connections by a process in this post.
Platforms: Windows.
Installation Steps:
You can easily install this Component Suite from GetIt Package Manager. The steps are as follows.
MiTeC Network Connections Demo
It’s that simple to monitor network connections established in your machine and view the details of the connections. Use this MiTeC component suite and get the job done with less code.
Head over and check out the full MiTec System Information Management Suite for Access System Information for Windows in Delphi Applications
February 12, 2021 By Anbarasan
Sometimes Developers may need to monitor the network connections by process running in a machine programmatically. How to list down the network connections between local and remote address, ports , protocol, status etc. ? Don’t know how to do. Don’t worry. Для просмотра ссылки Войди
Platforms: Windows.
Installation Steps:
You can easily install this Component Suite from GetIt Package Manager. The steps are as follows.
- Navigate In RAD Studio IDE->Tools->GetIt Package Manager->select Components in Categories->Components->Trail -MiTec system Information Component Suite 14.3 and click Install Button.
- Read the license and Click Agree All. An Information dialog saying ‘Requires a restart of RAD studio at the end of the process. Do you want to proceed? click yes and continue.
- It will download the plugin and installs it. Once installed Click Restart now.
- Navigate to the System Information Management Suite trails setup, Demos folder which is installed during Get It installation e.g) C:UsersDocumentsEmbarcaderoStudio21.0CatalogRepositoryMiTeC-14.3DemosDelphi20
- Open the NetCon project in RAD studio 10.4.1 compile and Run the application.
- This Demo App shows how to list down network connections by process in your machine and show the connection record properties.
- TNetConMonThread: Monitors network connections by processes in real-time and provides their properties. This class is singleton – it means it ensures to be instantiated only once per application.
- TListView for viewing network connections between peers.
- An instance FNCMof TNetConMonThread is created. And in regular interval of thread the Network connections list is refreshed and updated to the screen using the OnInterval Event handler.
- On each interval, the Network connections List( using TNetConRecord) is added to the list view by clearing the existing list and looping the RecordCount.
Код:
procedure TwndMain.RefreshList;
var
i,c: Integer;
vp: Integer;
SInfo: TScrollInfo;
r: TRect;
p: TNetConRecord;
s: string;
vi: TVersionInfo;
begin
SInfo.cbSize:=SizeOf(SInfo);
SInfo.fMask:=SIF_ALL;
GetScrollInfo(List.Handle,SB_VERT,SInfo);
vp:=SInfo.nPos;
List.Items.BeginUpdate;
try
List.Items.Clear;
c:=FNCM.RecordCount;
for i:=0 to c-1 do begin
FNCM.GetRecord(i,p);
p.ProcessName:=GetProcessName(p.PID);
FNCM.SetProcess(i,p.ProcessName,vi,-1);
with List.Items.Add do begin
Caption:=Format('%s (%d)',[p.ProcessName,p.PID]);
if not IsAddressNull(p.LocalAddress) then
SubItems.Add(p.LocalAddressString)
else
SubItems.Add(MachineName);
if p.LocalPort>0 then
SubItems.Add(IntToStr(p.LocalPort))
else
SubItems.Add('');
if not IsAddressNull(p.RemoteAddress) then
SubItems.Add(p.RemoteAddressString)
else if SameText('UDP',p.Protocol) then
SubItems.Add('')
else
SubItems.Add(MachineName);
if p.RemotePort>0 then
SubItems.Add(IntToStr(p.RemotePort))
else
SubItems.Add('');
s:=p.Protocol;
if p.Typ=AF_INET6 then
s:=s+'6';
SubItems.Add(s);
if SameText('TCP',p.Protocol) then
case p.State of
MIB_TCP_STATE_CLOSED: SubItems.Add('Closed');
MIB_TCP_STATE_LISTEN: SubItems.Add('Listen');
MIB_TCP_STATE_SYN_SENT: SubItems.Add('SYN sent');
MIB_TCP_STATE_SYN_RCVD: SubItems.Add('SYN received');
MIB_TCP_STATE_ESTAB: SubItems.Add('Established');
MIB_TCP_STATE_FIN_WAIT1: SubItems.Add('FIN wait 1');
MIB_TCP_STATE_FIN_WAIT2: SubItems.Add('FIN wait 2');
MIB_TCP_STATE_CLOSE_WAIT: SubItems.Add('Close wait');
MIB_TCP_STATE_CLOSING: SubItems.Add('Closing');
MIB_TCP_STATE_LAST_ACK: SubItems.Add('Last ACK');
MIB_TCP_STATE_TIME_WAIT: SubItems.Add('Time wait');
MIB_TCP_STATE_DELETE_TCB: SubItems.Add('Delete TCB');
else SubItems.Add('Unknown');
end
else
SubItems.Add('');
end;
end;
finally
List.Items.EndUpdate;
end;
if List.Items.Count>0 then begin
List.Items.BeginUpdate;
try
r:=List.Items[0].DisplayRect(drBounds);
List.Scroll(0,vp*(r.Bottom-r.Top));
finally
List.Items.EndUpdate;
end;
end;
sb.Panels[0].Text:=Format('%d item(s)',[List.Items.Count]);
end;
MiTeC Network Connections Demo
It’s that simple to monitor network connections established in your machine and view the details of the connections. Use this MiTeC component suite and get the job done with less code.
Head over and check out the full MiTec System Information Management Suite for Access System Information for Windows in Delphi Applications