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 78323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:58:10+00:00 2026-05-10T20:58:10+00:00

I’ve been using a 3G wireless card for a while and every time I

  • 0

I’ve been using a 3G wireless card for a while and every time I connect, my anti-virus fires up the updates.

I’m wondering what is the Win32 API set of functions that I can use to, either, get notified or query about the event of an Internet Connection coming up?

And is there already a set of ported headers for Delphi?

  • 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. 2026-05-10T20:58:10+00:00Added an answer on May 10, 2026 at 8:58 pm

    I worked on a project to run a user’s logon script whenever they connected our network over VPN. To do this, I wrote a helper unit that retrieves adapter info and stores it into a simple record.

    I then setup up a registry notification, see here for how to do that in Delphi

    The registry notification was on HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces. This notification event fires every time Windows obtains a new IP address, or makes any type of change to an adapters connection information. When this event fired, I called the function (in the code below) to retrieve updated information about the adapter. I compared this new information to my previously recorded information…meaning I had to save the previous adapter info query in order to know if something had changed.

    Anyhow, here is my helper unit:

    unit uAdapterInfo;  interface  uses   Classes,   SysUtils;  const   MAX_INTERFACE_NAME_LEN = $100;   ERROR_SUCCESS   = 0;   MAXLEN_IFDESCR  = $100;   MAXLEN_PHYSADDR = 8;    MIB_IF_OPER_STATUS_NON_OPERATIONAL = 0;   MIB_IF_OPER_STATUS_UNREACHABLE = 1;   MIB_IF_OPER_STATUS_DISCONNECTED = 2;   MIB_IF_OPER_STATUS_CONNECTING  = 3;   MIB_IF_OPER_STATUS_CONNECTED   = 4;   MIB_IF_OPER_STATUS_OPERATIONAL = 5;    MIB_IF_TYPE_OTHER    = 1;   MIB_IF_TYPE_ETHERNET = 6;   MIB_IF_TYPE_TOKENRING = 9;   MIB_IF_TYPE_FDDI     = 15;   MIB_IF_TYPE_PPP      = 23;   MIB_IF_TYPE_LOOPBACK = 24;   MIB_IF_TYPE_SLIP     = 28;    MIB_IF_ADMIN_STATUS_UP      = 1;   MIB_IF_ADMIN_STATUS_DOWN    = 2;   MIB_IF_ADMIN_STATUS_TESTING = 3;    _MAX_ROWS_ = 20;   ANY_SIZE   = 1;   type   MIB_IFROW = record     wszName:    array[0 .. (MAX_INTERFACE_NAME_LEN * 2 - 1)] of ansichar;     dwIndex:    longint;     dwType:     longint;     dwMtu:      longint;     dwSpeed:    longint;     dwPhysAddrLen: longint;     bPhysAddr:  array[0 .. (MAXLEN_PHYSADDR - 1)] of byte;     dwAdminStatus: longint;     dwOperStatus: longint;     dwLastChange: longint;     dwInOctets: longint;     dwInUcastPkts: longint;     dwInNUcastPkts: longint;     dwInDiscards: longint;     dwInErrors: longint;     dwInUnknownProtos: longint;     dwOutOctets: longint;     dwOutUcastPkts: longint;     dwOutNUcastPkts: longint;     dwOutDiscards: longint;     dwOutErrors: longint;     dwOutQLen:  longint;     dwDescrLen: longint;     bDescr:     array[0 .. (MAXLEN_IFDESCR - 1)] of ansichar;   end;  type   MIB_IPADDRROW = record     dwAddr:      longint;     dwIndex:     longint;     dwMask:      longint;     dwBCastAddr: longint;     dwReasmSize: longint;     unused1:     word;     unused2:     word;   end;  type   _IfTable = record     nRows: longint;     ifRow: array[1.._MAX_ROWS_] of MIB_IFROW;   end;  type   _IpAddrTable = record     dwNumEntries: longint;     table: array[1..ANY_SIZE] of MIB_IPADDRROW;   end;    function GetIfTable(pIfTable: Pointer; var pdwSize: longint; bOrder: longint): longint;   stdcall; function GetIpAddrTable(pIpAddrTable: Pointer; var pdwSize: longint;   bOrder: longint): longint; stdcall;  function Get_if_type(iType: integer): string; function Get_if_admin_status(iStatus: integer): string; function Get_if_oper_status(iStatus: integer): string;   implementation  function GetIfTable; stdcall; external 'IPHLPAPI.DLL'; function GetIpAddrTable; stdcall; external 'IPHLPAPI.DLL';  function Get_if_type(iType: integer): string; var   sResult: string; begin   sResult := 'UNKNOWN';   case iType of     1: sResult   := 'Other';     6: sResult   := 'Ethernet';     9: sResult   := 'Tokenring';     15: sResult  := 'FDDI';     23: sResult  := 'PPP';     24: sResult  := 'Local loopback';     28: sResult  := 'SLIP';     37: sResult  := 'ATM';     71: sResult  := 'IEEE 802.11';     131: sResult := 'Tunnel';     144: sResult := 'IEEE 1394 (Firewire)';   end;    Result := sResult; end;  function Get_if_admin_status(iStatus: integer): string; var   sResult: string; begin   sResult := 'UNKNOWN';    case iStatus of     1: sResult := 'UP';     2: sResult := 'DOWN';     3: sResult := 'TESTING';   end;    Result := sResult; end;  function Get_if_oper_status(iStatus: integer): string; var   sResult: string; begin   sResult := 'UNKNOWN';    case iStatus of     0: sResult := 'NON_OPERATIONAL';     1: sResult := 'UNREACHABLE';     2: sResult := 'DISCONNECTED';     3: sResult := 'CONNECTING';     4: sResult := 'CONNECTED';     5: sResult := 'OPERATIONAL';   end;    Result := sResult; end;  end. 

    To use this unit from another unit, I created the following function, which populated a custom type called TAdapterInfo (declared in my main unit):

    type   TAdapterInfo = array of record     dwIndex:    longint;     dwType:     longint;     dwMtu:      longint;     dwSpeed:    extended;     dwPhysAddrLen: longint;     bPhysAddr:  string;     dwAdminStatus: longint;     dwOperStatus: longint;     dwLastChange: longint;     dwInOctets: longint;     dwInUcastPkts: longint;     dwInNUcastPkts: longint;     dwInDiscards: longint;     dwInErrors: longint;     dwInUnknownProtos: longint;     dwOutOctets: longint;     dwOutUcastPkts: longint;     dwOutNUcastPkts: longint;     dwOutDiscards: longint;     dwOutErrors: longint;     dwOutQLen:  longint;     dwDescrLen: longint;     bDescr:     string;     sIpAddress: string;     sIpMask:    string;   end; 

    //////////

    function Get_EthernetAdapterDetail(var AdapterDataFound: TAdapterInfo): boolean; var   pIfTable: ^_IfTable;   pIpTable: ^_IpAddrTable;   ifTableSize, ipTableSize: longint;   tmp:      string;   i, j, k, m: integer;   ErrCode:  longint;   sAddr, sMask: in_addr;   IPAddresses, IPMasks: TStringList;   sIPAddressLine, sIPMaskLine: string;   bResult:  boolean; begin   bResult  := True; //default return value   pIfTable := nil;   pIpTable := nil;    IPAddresses := TStringList.Create;   IPMasks     := TStringList.Create;    try     // First: just get the buffer size.     // TableSize returns the size needed.     ifTableSize := 0; // Set to zero so the GetIfTabel function     // won't try to fill the buffer yet,     // but only return the actual size it needs.     GetIfTable(pIfTable, ifTableSize, 1);     if (ifTableSize < SizeOf(MIB_IFROW) + Sizeof(longint)) then     begin       bResult := False;       Result  := bResult;       Exit; // less than 1 table entry?!     end;      ipTableSize := 0;     GetIpAddrTable(pIpTable, ipTableSize, 1);     if (ipTableSize < SizeOf(MIB_IPADDRROW) + Sizeof(longint)) then     begin       bResult := False;       Result  := bResult;       Exit; // less than 1 table entry?!     end;      // Second:     // allocate memory for the buffer and retrieve the     // entire table.     GetMem(pIfTable, ifTableSize);     ErrCode := GetIfTable(pIfTable, ifTableSize, 1);      if ErrCode <> ERROR_SUCCESS then     begin       bResult := False;       Result  := bResult;       Exit; // OK, that did not work.        // Not enough memory i guess.     end;      GetMem(pIpTable, ipTableSize);     ErrCode := GetIpAddrTable(pIpTable, ipTableSize, 1);      if ErrCode <> ERROR_SUCCESS then     begin       bResult := False;       Result  := bResult;       Exit;     end;      for k := 1 to pIpTable^.dwNumEntries do     begin       sAddr.S_addr := pIpTable^.table[k].dwAddr;       sMask.S_addr := pIpTable^.table[k].dwMask;        sIPAddressLine := Format('0x%8.8x', [(pIpTable^.table[k].dwIndex)]) +         '=' + Format('%s', [inet_ntoa(sAddr)]);       sIPMaskLine    := Format('0x%8.8x', [(pIpTable^.table[k].dwIndex)]) +         '=' + Format('%s', [inet_ntoa(sMask)]);        IPAddresses.Add(sIPAddressLine);       IPMasks.Add(sIPMaskLine);     end;      SetLength(AdapterDataFound, pIfTable^.nRows); //initialize the array or records     for i := 1 to pIfTable^.nRows do       try         //if pIfTable^.ifRow[i].dwType=MIB_IF_TYPE_ETHERNET then         //begin         m := i - 1;         AdapterDataFound[m].dwIndex := 4;//(pIfTable^.ifRow[i].dwIndex);         AdapterDataFound[m].dwType := (pIfTable^.ifRow[i].dwType);         AdapterDataFound[m].dwIndex := (pIfTable^.ifRow[i].dwIndex);         AdapterDataFound[m].sIpAddress :=           IPAddresses.Values[Format('0x%8.8x', [(pIfTable^.ifRow[i].dwIndex)])];         AdapterDataFound[m].sIpMask :=           IPMasks.Values[Format('0x%8.8x', [(pIfTable^.ifRow[i].dwIndex)])];         AdapterDataFound[m].dwMtu := (pIfTable^.ifRow[i].dwMtu);         AdapterDataFound[m].dwSpeed := (pIfTable^.ifRow[i].dwSpeed);         AdapterDataFound[m].dwAdminStatus := (pIfTable^.ifRow[i].dwAdminStatus);         AdapterDataFound[m].dwOperStatus := (pIfTable^.ifRow[i].dwOperStatus);         AdapterDataFound[m].dwInUcastPkts := (pIfTable^.ifRow[i].dwInUcastPkts);         AdapterDataFound[m].dwInNUcastPkts := (pIfTable^.ifRow[i].dwInNUcastPkts);         AdapterDataFound[m].dwInDiscards := (pIfTable^.ifRow[i].dwInDiscards);         AdapterDataFound[m].dwInErrors := (pIfTable^.ifRow[i].dwInErrors);         AdapterDataFound[m].dwInUnknownProtos := (pIfTable^.ifRow[i].dwInUnknownProtos);         AdapterDataFound[m].dwOutNUcastPkts := (pIfTable^.ifRow[i].dwOutNUcastPkts);         AdapterDataFound[m].dwOutUcastPkts := (pIfTable^.ifRow[i].dwOutUcastPkts);         AdapterDataFound[m].dwOutDiscards := (pIfTable^.ifRow[i].dwOutDiscards);         AdapterDataFound[m].dwOutErrors := (pIfTable^.ifRow[i].dwOutErrors);         AdapterDataFound[m].dwOutQLen := (pIfTable^.ifRow[i].dwOutQLen);         AdapterDataFound[m].bDescr := (pIfTable^.ifRow[i].bDescr);          tmp := '';         for j := 0 to pIfTable^.ifRow[i].dwPhysAddrLen - 1 do         begin           if Length(tmp) > 0 then             tmp := tmp + '-' + format('%.2x', [pIfTable^.ifRow[i].bPhysAddr[j]])           else             tmp := tmp + format('%.2x', [pIfTable^.ifRow[i].bPhysAddr[j]]);         end;          if Length(tmp) > 0 then         begin           AdapterDataFound[m].bPhysAddr := tmp;         end;       except         bResult := False;         Result  := bResult;         Exit;       end;   finally     if Assigned(pIfTable) then     begin       FreeMem(pIfTable, ifTableSize);     end;      FreeAndNil(IPMasks);     FreeAndNil(IPAddresses);   end;    Result := bResult; end; 

    On a completely side note, I also used this unit and almost exact same code to create a duplicate of ifconfig -a, which can be found on github. I mainly did it as an exercise in teaching myself how to accomplish this task.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer NSImage is an abstract data type that can represent many… May 11, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer First of all, to send the screenshot, you can use… May 11, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer I figured it out: window.nativeWindow.x = (Screen.mainScreen.bounds.width - window.width)/2; window.nativeWindow.y… May 11, 2026 at 11:41 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.