Query ICS external adapter on Windows 10 or 11

Hao Zhuang 1 Reputation point
2022-01-20T00:34:00.863+00:00

I need to programmatically find the external (Internet) adapter (network interface), either GUID, LUID or InterfaceIndex, used for Internet Connection Sharing service. There is a reg value entry under HKLM\System\CCS\Services\icssvc\Settings of the "PreferredPublicInterface". But I'm afraid it is not the right way to do it. Could you please advise what APIs can be used to retrieve this information on Windows 10 or 11?

Thanks in advance!

Windows development | Windows API - Win32
Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
{count} votes

2 answers

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2022-01-20T02:39:16.057+00:00

    Hello,

    Welcome to Microsoft Q&A!

    the GetAdaptersAddresses and GetInterfaceInfo functions can retrieve all adapters information on the local computer. But I don’t know the PreferredPublicInterface meaning.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Limitless Technology 39,931 Reputation points
    2022-01-21T09:55:29.587+00:00

    Hello HaoZhuang

    You can use WMI instance to retrieve the information, for example:

    Get-CimInstance -Class CIM_NetworkAdapter -ComputerName localhost -ErrorAction Stop | Select-Object *

    This will show you all the properties, then you can select the one you want.


    --If the reply is helpful, please Upvote and Accept as answer--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.