code: def get_windows_interfaces():
      
  
      import win32com.client
      import pywintypes
  
      interfaces = []
      try:
          locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
          service = locator.ConnectServer(".", "root\cimv2")
          network_configs = service.InstancesOf("Win32_NetworkAdapterConfiguration")
          # more info on Win32_NetworkAdapter: http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx
          for adapter in service.InstancesOf("Win32_NetworkAdapter"):
              if adapter.NetConnectionStatus == 2 or adapter.NetConnectionStatus == 7:
                  # adapter is connected or media disconnected
                  ip_address = ""
                  netmask = ""
                  for network_config in network_configs:
                      if network_config.InterfaceIndex == adapter.InterfaceIndex:
                          if network_config.IPAddress:
                              # get the first IPv4 address only
                              ip_address = network_config.IPAddress[0]
                              netmask = network_config.IPSubnet[0]
                          break
                  npf_interface = "\\Device\\NPF_{guid}".format(guid=adapter.GUID)
                  interfaces.append({"id": npf_interface,
                                     "name": adapter.NetConnectionID,
                                     "ip_address": ip_address,
                                     "mac_address": adapter.MACAddress,
                                     "netcard": adapter.name,
                                     "netmask": netmask,
                                     "type": "ethernet"})
      except (AttributeError, pywintypes.com_error):
          log.warn("Could not use the COM service to retrieve interface info, trying using the registry...")
          return _get_windows_interfaces_from_registry()
  
      return interfaces
docs: Get Windows interfaces.
  
      :returns: list of windows interfaces