Added code to delete any kernel driver service that can't be opened before reinstalling it.

This commit is contained in:
Michael Möller 2011-02-11 22:29:26 +00:00
parent d1a963aa55
commit 46e4752c8f
2 changed files with 9 additions and 5 deletions

View File

@ -112,7 +112,9 @@ namespace OpenHardwareMonitor.Hardware {
driver.Open();
if (!driver.IsOpen) {
// driver is not loaded, try to install and open
// driver is not loaded, try to reinstall and open
driver.Delete();
string fileName = Path.GetTempFileName();
if (ExtractDriver(fileName)) {
if (driver.Install(fileName)) {
@ -124,7 +126,9 @@ namespace OpenHardwareMonitor.Hardware {
report.AppendLine("Status: Opening driver failed");
}
} else {
report.AppendLine("Status: Installing driver failed");
report.AppendLine("Status: Installing driver \"" +
fileName + "\" failed" +
(File.Exists(fileName) ? " and file exists" : ""));
report.AppendLine();
report.Append("Exception: " + Marshal.GetExceptionForHR(
Marshal.GetHRForLastWin32Error()).Message);

View File

@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -37,5 +37,5 @@
using System.Reflection;
[assembly: AssemblyVersion("0.2.1.12")]
[assembly: AssemblyInformationalVersion("0.2.1.12 Alpha")]
[assembly: AssemblyVersion("0.2.1.13")]
[assembly: AssemblyInformationalVersion("0.2.1.13 Alpha")]