/// <summary> /// Get all adapters in the system. /// /// For the NDIS_MEDIUM enumeration: 0 - NdisMedium802_3; 16 - NdisMediumNative802_11 /// </summary> /// <returns></returns> private List <NM_NIC_ADAPTER_INFO> GetAdapters() { uint errno; uint adapterCnt; List <NM_NIC_ADAPTER_INFO> adapters = new List <NM_NIC_ADAPTER_INFO>(); if (this.captureEngineHandle != IntPtr.Zero) { errno = NetmonAPI.NmGetAdapterCount(this.captureEngineHandle, out adapterCnt); if (errno == 0) { for (uint i = 0; i < adapterCnt; i++) { NM_NIC_ADAPTER_INFO adapterInfo = new NM_NIC_ADAPTER_INFO(); adapterInfo.Size = (ushort)System.Runtime.InteropServices.Marshal.SizeOf(typeof(NM_NIC_ADAPTER_INFO)); errno = NetmonAPI.NmGetAdapter(this.captureEngineHandle, i, ref adapterInfo); if (errno == 0) { //Only take Ethernet or 802.11 wireless adapters. if (adapterInfo.MediaType == 0 || (uint)adapterInfo.MediaType == 16) { adapters.Add(adapterInfo); } } else { throw new Exception("NmGetAdapter() failed. Error=" + errno); } } } } return(adapters); }