示例#1
0
        /// <summary>Constructs a new instance of the DIFx class.</summary>
        public DIFx()
        {
            this.tempPath = Path.GetTempFileName();
            ExtractDLL();

            handle = InteropKernel.LoadLibrary(tempPath);
            if (handle == IntPtr.Zero)
            {
                throw new Exception("LoadLibrary failed to load the extracted DIFx library.");
            }
        }
示例#2
0
        /// <summary>Uninstall the specified INF file.</summary>
        /// <returns>True if uninstallation is complete, else false if a reboot is required to complete uninstallation. May throw upon errors.</returns>
        public bool DriverPackageUninstall(string infPath, DriverPackageFlags flags)
        {
            bool rebootRequired;
            var  proc = InteropKernel.GetProcAddress(handle, "DriverPackageUninstallW");
            var  uninstallDelegate = (Interop.DriverPackageUninstall)Marshal.GetDelegateForFunctionPointer(proc, typeof(Interop.DriverPackageUninstall));
            var  r = uninstallDelegate(infPath, (UInt32)flags, IntPtr.Zero, out rebootRequired);

            if (r != 0)
            {
                throw new DriverPackageException(r, "DriverPackageUninstall failed with DIFxAPI error 0x" + r.ToString("X8"));
            }

            return(!rebootRequired);
        }
示例#3
0
        /// <summary>Dispose any resources used by DIFx.</summary>
        public void Dispose()
        {
            if (handle != IntPtr.Zero)
            {
                InteropKernel.FreeLibrary(handle);
                handle = IntPtr.Zero;
            }

            if (this.tempPath != null)
            {
                File.Delete(this.tempPath);
                this.tempPath = null;
            }
        }