public static void Close() { if (driver != null) { uint refCount = 0; driver.DeviceIOControl(IOCTL_OLS_GET_REFCOUNT, null, ref refCount); driver.Close(); if (refCount <= 1) { driver.Delete(); } driver = null; } if (isaBusMutex != null) { isaBusMutex.Close(); isaBusMutex = null; } // try to delete temporary driver file again if failed during open if (fileName != null && File.Exists(fileName)) { try { File.Delete(fileName); fileName = null; } catch (IOException) { } catch (UnauthorizedAccessException) { } } }
public static void UninstallKernelDriver() { InitializeKernelDriver(); if (driver != null) { try { if (driver.IsOpen) { driver.Close(); } driver.Delete(); driver = null; } catch { report.AppendLine("Status: Uninstalling driver failed"); } } }
public static void Close() { if (driver == null) { return; } uint refCount = 0; driver.DeviceIOControl(IOCTL_OLS_GET_REFCOUNT, null, ref refCount); driver.Close(); if (refCount <= 1) { driver.Delete(); } driver = null; isaBusMutex.Close(); }