public static int QueryAdapter(string adapterName, out INTF_ENTRY entry) { // Attempt to get the status of the indicated // interface by calling WZCQueryInterface. If // it works, we return true; if not, false. // Note that the first parameter, the WZC server, // is set to null, apparently indicating that the // local machine is the target. entry = new INTF_ENTRY(); INTF_FLAGS flags = 0; entry.Guid = adapterName; int retVal = 0; try { retVal = WZC.WZCQueryInterface(null, INTF_FLAGS.INTF_ALL, ref entry, out flags); } catch (Exception ex) { // on a throw, the return value needs to get set to a non-zero try { WZC.WZCDeleteIntfObj(ref entry); } catch { } return(-1); } return(retVal); }
/// <summary> /// Creates a new entry with given name in memory /// </summary> /// <param name="guid">Name</param> /// <returns>Entry</returns> public static INTF_ENTRY GetEntry(string guid) { INTF_ENTRY entry = new INTF_ENTRY(); entry.Guid = guid; INTF_FLAGS dwOutFlags; int uret = WZC.WZCQueryInterface(null, INTF_FLAGS.INTF_ALL, ref entry, out dwOutFlags); if (uret > 0) { throw new NetworkInformationException(uret); } return(entry); }