[Solved] How to find Network Connection Name (not Interface name)? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- loaded · 2022-05-09 10:52 Hi All, I am getting the Network Connections information with the code below. Quote from: paweld on April 09, 2022, 10:33:32 amfrom: https://stackoverflow.com/questions/18378630/get-information-about- the-installed-network-adapters Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  jwawindows; procedure TForm1.Button1Click(Sender: TObject);var  pAdapterInfo: PIP_ADAPTER_INFO;  AdapterInfo: IP_ADAPTER_INFO;  BufLen: DWORD;  Status: DWORD;  strMAC: String;  i: Integer;begin  BufLen:= sizeof(AdapterInfo);  pAdapterInfo:= @AdapterInfo;  Status:= GetAdaptersInfo(nil, BufLen);  pAdapterInfo:= AllocMem(BufLen);  try  Status:= GetAdaptersInfo(pAdapterInfo, BufLen);    if (Status <> ERROR_SUCCESS) then    begin      case Status of        ERROR_NOT_SUPPORTED: Memo1.Lines.Add('GetAdaptersInfo is not supported by the operating ' +          'system running on the local computer.');        ERROR_NO_DATA: Memo1.Lines.Add('No network adapter on the local computer.');      else        Memo1.Lines.Add('GetAdaptersInfo failed with error #' + IntToStr(Status));      end;      Dispose(pAdapterInfo);      exit;  end;     while (pAdapterInfo <> nil) do    begin      memo1.Lines.Add('----------------------------------------------');    memo1.Lines.Add('Description: ' + pAdapterInfo^.Description);      memo1.Lines.Add('Name: ' + pAdapterInfo^.AdapterName);      //strMAC := '';      //for i := 0 to pAdapterInfo^.AddressLength - 1 do      //   strMAC := strMAC + '-' + IntToHex(pAdapterInfo^.Address[i], 2);    //memo1.Lines.Add('MAC address: ' + Copy(strMAC, 2, Length(strMAC) - 1));      //memo1.Lines.Add('IP address: ' + pAdapterInfo^.IpAddressList.IpAddress.S);      //memo1.Lines.Add('IP subnet mask: ' + pAdapterInfo^.IpAddressList.IpMask.S);      memo1.Lines.Add('Gateway: ' + pAdapterInfo^.GatewayList.IpAddress.S);      //memo1.Lines.Add('DHCP enabled: ' + IntTOStr(pAdapterInfo^.DhcpEnabled));      //memo1.Lines.Add('DHCP: ' + pAdapterInfo^.DhcpServer.IpAddress.S);      //memo1.Lines.Add('Have WINS: ' + BoolToStr(pAdapterInfo^.HaveWins,True));      //memo1.Lines.Add('Primary WINS: ' + pAdapterInfo^.PrimaryWinsServer.IpAddress.S);      //memo1.Lines.Add('Secondary WINS: ' + pAdapterInfo^.SecondaryWinsServer.IpAddress.S);      pAdapterInfo:= pAdapterInfo^.Next;    end;  finally    Dispose(pAdapterInfo);  end;end; But the connection name looks like CLSID. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Description: Remote NDIS based Internet Sharing DeviceName: {3B8EBC10-065D-46FE-A27C-D13322904BD9}Gateway: 192.168.42.129 Is there a way to get the name of the network connection in plain readable text? Or will I have to use a different method? ---------------------------------------------------------------------- PascalDragon · 2022-05-09 11:14 Quote from: loaded on May 09, 2022, 12:52:02 pmIs there a way to get the name of the network connection in plain readable text? Or will I have to use a different method? The Description is the plain readable name of the adapter. If you mean something like “LAN Connection 1” or so then it seems that you'll need to retrieve that differently (no, I don't know how). ---------------------------------------------------------------------- loaded · 2022-05-09 11:21 Quote from: PascalDragon on May 09, 2022, 01:14:15 pmIf you mean something like “LAN Connection 1” or so then it seems that you'll need to retrieve that differently (no, I don't know how). Thank you so much for the reply PascalDragon. Yes this is exactly what i want ---------------------------------------------------------------------- Zvoni · 2022-05-09 13:30 Why not Query the WMI? This one's "deprecated" https://docs.microsoft.com/en- us/windows/win32/cimwin32prov/win32-networkadapter?redirectedfrom=MSDN Or this one https://docs.microsoft.com/en- us/windows/win32/cimwin32prov/win32-networkadapterconfiguration No idea which Property it is EDIT: Found it. It's the class "Win32_NetworkAdapter" (Remember: "Deprecated") The Property "NetConnectionID" --> returns "Ethernet 4" for my card EDIT2: Also found this: https://forum.lazarus.freepascal.org/index.php?topic=24490.0 EDIT 3: Have you thought about looking for that Class-ID in the Registry? Path: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\ Digging there i found my "Ethernet 4", too QuoteBut the connection name looks like CLSID.     Description: Remote NDIS based Internet Sharing Device     Name: {3B8EBC10-065D-46FE-A27C-D13322904BD9}     Gateway: 192.168.42.129 ---------------------------------------------------------------------- bobby100 · 2022-05-09 14:25 Or you can take a look at my code here and modify it to your needs: https://forum.lazarus.freepascal.org/index.php/topic,57807.0.html ---------------------------------------------------------------------- loaded · 2022-05-09 18:02 First of all, I can't thank you enough Zvoni and bobby100 for taking your precious time to reply. Quote from: Zvoni on May 09, 2022, 03:30:22 pmWhy not Query the WMI? I didn't know about WMI Usage. Thank you very much, I learned from you. Quote from: Zvoni on May 09, 2022, 03:30:22 pmEDIT2: Also found this: https://forum.lazarus.freepascal.org/index.php?topic=24490.0 This is the solution I'm looking for. I take this opportunity to thank you at Jurassic Pork. Quote from: bobby100 on May 09, 2022, 04:25:48 pmOr you can take a look at my code here and modify it to your needs: https://forum.lazarus.freepascal.org/index.php/topic,57807.0.html I tried your solution as well, but the solution in EDIT2 above seemed a little easier to me. Thank you very much. Regards.