Added a check if all required files are available at startup. Improved the crash reporting.

This commit is contained in:
Michael Möller
2010-05-01 12:12:37 +00:00
parent 634300c15a
commit b4b40b7f8e
3 changed files with 93 additions and 22 deletions
+34
View File
@@ -57,6 +57,9 @@ namespace OpenHardwareMonitor {
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
#endif
if (!AllRequiredFilesAvailable())
Environment.Exit(0);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (GUI.MainForm form = new GUI.MainForm()) {
@@ -67,6 +70,37 @@ namespace OpenHardwareMonitor {
}
}
private static bool IsFileAvailable(string fileName) {
string path = Path.GetDirectoryName(Application.ExecutablePath) +
Path.DirectorySeparatorChar;
if (!File.Exists(path + fileName)) {
MessageBox.Show("The following file could not be found: " + fileName +
"\nPlease extract all files from the zip archive.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}
private static bool AllRequiredFilesAvailable() {
if (!IsFileAvailable("Aga.Controls.dll"))
return false;
if (IntPtr.Size == 4) {
if (!IsFileAvailable("WinRing0.dll"))
return false;
if (!IsFileAvailable("WinRing0.sys"))
return false;
} else {
if (!IsFileAvailable("WinRing0x64.dll"))
return false;
if (!IsFileAvailable("WinRing0x64.sys"))
return false;
}
return true;
}
private static void ReportException(Exception e) {
CrashReportForm form = new CrashReportForm();
form.Exception = e;