Check whether Ftd2xx DLL exists.

This commit is contained in:
PhyxionNL
2020-12-07 11:57:54 +01:00
parent 18232fd182
commit 1d21c74e68
2 changed files with 18 additions and 13 deletions
@@ -25,25 +25,19 @@ namespace LibreHardwareMonitor.Hardware.Controller.TBalancer
uint numDevices;
try
{
if (!Ftd2xx.DllExists())
{
_report.AppendLine("Status: missing DLL");
return;
}
if (Ftd2xx.FT_CreateDeviceInfoList(out numDevices) != Ftd2xx.FT_STATUS.FT_OK)
{
_report.AppendLine("Status: FT_CreateDeviceInfoList failed");
return;
}
}
catch (DllNotFoundException)
{
return;
}
catch (ArgumentNullException)
{
return;
}
catch (EntryPointNotFoundException)
{
return;
}
catch (BadImageFormatException)
catch (Exception e) when (e is DllNotFoundException || e is ArgumentNullException || e is EntryPointNotFoundException || e is BadImageFormatException)
{
return;
}
+11
View File
@@ -14,6 +14,17 @@ namespace LibreHardwareMonitor.Interop
{
private const string DllName = "Ftd2xx.dll";
public static bool DllExists()
{
IntPtr module = Kernel32.LoadLibrary(DllName);
if (module == IntPtr.Zero)
return false;
Kernel32.FreeLibrary(module);
return true;
}
[DllImport(DllName)]
public static extern FT_STATUS FT_CreateDeviceInfoList(out uint numDevices);