Пример #1
0
        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);
        }
Пример #2
0
 public void Dispose()
 {
     if (wszDescr != IntPtr.Zero)
     {
         Marshal.FreeHGlobal(this.wszDescr);
     }
     if (wszGuid != IntPtr.Zero)
     {
         Marshal.FreeHGlobal(this.wszGuid);
     }
     if (bInitialized != 0)
     {
         WZC.WZCDeleteIntfObj(ref this);
     }
 }