Do you need to access Network Adapter information from your Delphi applications? Detecting the available network adapters information is no longer a challenging task. MiTec’s System Information Management Suite’s component helps to detect the network adapters easily, and we will learn how to use TMiTeC_Network and TMiTeC_TCPIP components in this blog post.
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.
How to run the Demo app:
- Navigate to the System Information Management Suite trails setup, Demos folder which is installed during Get It installation e.g) C:UsersDocumentsEmbarcaderoStudio21.0CatalogRepositoryMiTeC-14.3DemosDelphi17
- Open the IntfList project in RAD studio 10.4.1 compile and Run the application.
- This Demo App shows how to detect the Network Adapters and its properties such as Interface, IPAddress, MACAddress etc.
Components used in MSIC IntfList Demo App:
- TMiTeC_Network: Retrieves network environment information. Using this component, we can access Network resources and WinSock properties.
- TMiTeC_TCPIP: Enumerates network adapters, their properties and network configuration.
- TListView To list down the list of detected TCPIP Network Adapters.
Implementation Details:
- An instance FNetwork of TMiTeC_Network is created. Loop through the TCPIP.AdapterCount property to detect the available network adapters. For each TCPIP.Adpater record list down the properties such as Interface Name, IPAddress, IPAddressMask, Address, Typ, OperStatus, AdminStatus, Speed in the list view.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
procedure TwndMain.RefreshData; var i: Integer; begin FNetwork.RefreshData; List.Items.BeginUpdate; try List.Items.Clear; for i:=0 to FNetwork.TCPIP.AdapterCount-1 do with List.Items.Add do begin Caption:=FNetwork.TCPIP.Adapter[i].Name; SubItems.Add(FNetwork.TCPIP.Adapter[i].IPAddress.CommaText); SubItems.Add(FNetwork.TCPIP.Adapter[i].IPAddressMask.CommaText); SubItems.Add(FNetwork.TCPIP.Adapter[i].Address); SubItems.Add(AdapterTypes[FNetwork.TCPIP.Adapter[i].Typ]); SubItems.Add(GetIntfStatStr(FNetwork.TCPIP.Adapter[i].OperStatus)); SubItems.Add(GetIntfAdminStr(FNetwork.TCPIP.Adapter[i].AdminStatus)); SubItems.Add(IntToStr(FNetwork.TCPIP.Adapter[i].MaxSpeed div 1000000)); SubItems.Add(IntToStr(FNetwork.TCPIP.Adapter[i].MTU)); if FNetwork.TCPIP.BestInterfaceIdx=FNetwork.TCPIP.Adapter[i].IntfIdx then ImageIndex:=0 else ImageIndex:=-1; end; finally List.Items.EndUpdate; end; end; |
- On Double clicking a selected row, the interface properties were shown in the child form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
procedure ShowIntfProps(Adapter: TAdapter); begin dlgIntf:=TdlgIntf.Create(Application.Mainform); with dlgIntf do try Caption:=Adapter.Name; with List.Items.Add do begin Caption:='Description'; SubItems.Add(Adapter.Name); end; with List.Items.Add do begin Caption:='Alias'; SubItems.Add(Adapter.Alias); end; with List.Items.Add do begin Caption:='MAC Address'; SubItems.Add(Adapter.Address); end; with List.Items.Add do begin Caption:='MTU'; SubItems.Add(IntToStr(Adapter.MTU)); end; with List.Items.Add do begin Caption:='Link speed'; SubItems.Add(Format('%d Mbps',[Adapter.MaxSpeed div 1000000])); end; with List.Items.Add do begin Caption:='Type'; SubItems.Add(AdapterTypes[Adapter.Typ]); end; with List.Items.Add do begin Caption:='DNS connection suffix'; SubItems.Add(Adapter.DNSSuffix); end; with List.Items.Add do begin Caption:='DHCP Enabled'; SubItems.Add(BoolToStr(Adapter.EnableDHCP,True)); end; with List.Items.Add do begin Caption:='IPv4'; SubItems.Add(Adapter.IPAddress.CommaText); end; with List.Items.Add do begin Caption:='IPv4 Mask'; SubItems.Add(Adapter.IPAddressMask.CommaText); end; with List.Items.Add do begin Caption:='IPv4 DHCP Servers'; SubItems.Add(Adapter.DHCP_IPAddress.CommaText); end; with List.Items.Add do begin Caption:='IPv4 Default Gateway'; SubItems.Add(Adapter.Gateway_IPAddress.CommaText); end; with List.Items.Add do begin Caption:='IPv4 DNS Servers'; SubItems.Add(Adapter.DNSServers.CommaText); end; with List.Items.Add do begin Caption:='IPv4 WINS Servers'; SubItems.Add(Adapter.PrimaryWINS_IPAddress.CommaText); end; with List.Items.Add do begin Caption:='IPv6'; SubItems.Add(Adapter.IPv6Address.CommaText); end; with List.Items.Add do begin Caption:='IPv6 DHCP Servers'; SubItems.Add(Adapter.DHCP_IPv6.CommaText); end; with List.Items.Add do begin Caption:='IPv6 Default Gateway'; SubItems.Add(Adapter.Gateway_IPv6.CommaText); end; with List.Items.Add do begin Caption:='IPv6 DNS Servers'; SubItems.Add(Adapter.DNSServers_IPv6.CommaText); end; with List.Items.Add do begin Caption:='IPv6 WINS Servers'; SubItems.Add(Adapter.PrimaryWINS_IPv6.CommaText); end; ShowModal; finally Free; end; end; |
It’s that simple to enumerate a list of network adapters and their properties available on your machine from your Delphi application. Use this MiTeC component suite and get the job done quickly.
With the use of a Windows IDE, you can easily detect the network adapters in your windows apps with a component suite. Try your Free Trial here.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition