Check whether Ftd2xx DLL exists.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user