Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6156275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:34:54+00:00 2026-05-23T20:34:54+00:00

I have been given a task of finding the info abt n/w or, the

  • 0

I have been given a task of finding the info abt n/w or, the info which is given by the netstat command in Windows. Now, I have been told to use some API for extracting that information. Any API which is available for delphi 7 for this task will be helpful.
I have come across this API, the IP helper API , but i cannot find that in my PC. i could only find the DLL ‘iphlpapi.dll’ in C:\Windows\System32. Also, there seems to be very less information on how to use this particular API. Please help.

Thanks IN advance

P.S. Earlier i was doing the same by executing the Netstat command, writing the output to a text file, and then parsing the same for display, which for me, is a Perfectly fine approach. My sir however is not fine with it. What is the cause, i could not fathom.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:34:55+00:00Added an answer on May 23, 2026 at 8:34 pm

    Check these windows functions GetTcpTable, GetUdpTable, GetExtendedTcpTable, GetExtendedUdpTable.

    UPDATE

    {$APPTYPE CONSOLE}
    
    uses
      WinSock,
      Windows,
      SysUtils;
    
    const
       ANY_SIZE = 1;
       iphlpapi = 'iphlpapi.dll';
       TCP_TABLE_OWNER_PID_ALL = 5;
    
       MIB_TCP_STATE:
       array[1..12] of string = ('CLOSED', 'LISTEN', 'SYN-SENT ','SYN-RECEIVED', 'ESTABLISHED', 'FIN-WAIT-1',
                                 'FIN-WAIT-2', 'CLOSE-WAIT', 'CLOSING','LAST-ACK', 'TIME-WAIT', 'delete TCB');
    
    type
      TCP_TABLE_CLASS = Integer;
    
      PMibTcpRowOwnerPid = ^TMibTcpRowOwnerPid;
      TMibTcpRowOwnerPid  = packed record
        dwState     : DWORD;
        dwLocalAddr : DWORD;
        dwLocalPort : DWORD;
        dwRemoteAddr: DWORD;
        dwRemotePort: DWORD;
        dwOwningPid : DWORD;
        end;
    
      PMIB_TCPTABLE_OWNER_PID  = ^MIB_TCPTABLE_OWNER_PID;
      MIB_TCPTABLE_OWNER_PID = packed record
       dwNumEntries: DWORD;
       table: Array [0..ANY_SIZE - 1] of TMibTcpRowOwnerPid;
      end;
    
    var
       GetExtendedTcpTable:function  (pTcpTable: Pointer; dwSize: PDWORD; bOrder: BOOL; lAf: ULONG; TableClass: TCP_TABLE_CLASS; Reserved: ULONG): DWord; stdcall;
    
    procedure ShowCurrentTCPConnections;
    var
       Error      : DWORD;
       TableSize  : DWORD;
       i          : integer;
       IpAddress  : in_addr;
       RemoteIp   : string;
       LocalIp    : string;
       pTcpTable  : PMIB_TCPTABLE_OWNER_PID;
    begin
      TableSize := 0;
      //Get the size o the tcp table
      Error := GetExtendedTcpTable(nil, @TableSize, False, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0);
      if Error <> ERROR_INSUFFICIENT_BUFFER then exit;
    
      //alocate the buffer
      GetMem(pTcpTable, TableSize);
      try
       Writeln(Format('%-16s %-6s %-16s %-6s %s',['Local IP','Port','Remote IP','Port','Status']));
       //get the tcp table data
       if GetExtendedTcpTable(pTcpTable, @TableSize, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0) = NO_ERROR then
          for i := 0 to pTcpTable.dwNumEntries - 1 do
          begin
             IpAddress.s_addr := pTcpTable.Table[i].dwRemoteAddr;
             RemoteIp         := string(inet_ntoa(IpAddress));
             IpAddress.s_addr := pTcpTable.Table[i].dwLocalAddr;
             LocalIp          := string(inet_ntoa(IpAddress));
             Writeln(Format('%-16s %-6d %-16s %-6d %s',[LocalIp,pTcpTable.Table[i].dwLocalPort,RemoteIp,pTcpTable.Table[i].dwRemotePort,MIB_TCP_STATE[pTcpTable.Table[i].dwState]]));
          end;
      finally
         FreeMem(pTcpTable);
      end;
    end;
    
    var
       hModule : THandle;
    begin
      try
        hModule             := LoadLibrary(iphlpapi);
        GetExtendedTcpTable := GetProcAddress(hModule, 'GetExtendedTcpTable');
        ShowCurrentTCPConnections;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
      Readln;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been given the task of re-writing some libraries written in C# so
I have been given a task of inputting some student data, like option 1:
I have been given a task of creating a common Gridview component which has
I have been given the task to evaluate codeFirst and possible to use for
I have been given the task of calling a web service which returns an
I have been given the task of finding a replacement for a piece of
I have been given the task to fix an Embedded Operating System which is
I have been given a task where I have to write some code for
I have a ASP.NET MVC membership project, now I have been given the task
I have been given the task of adding functionality to an existing IIS 6.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.