Thanks to @KyodaiKen
This commit is contained in:
Phyxion
2019-10-14 10:43:04 +02:00
committed by GitHub
parent 059b43cc14
commit d26ccfdbce
+5 -2
View File
@@ -12,6 +12,8 @@ namespace LibreHardwareMonitor.Interop
internal static class NvidiaML
{
private const string LinuxDllName = "nvidia-ml";
private const string WindowsDllName = "nvml.dll";
private static WindowsNvmlGetHandleDelegate _windowsNvmlDeviceGetHandleByIndex;
private static WindowsNvmlGetPowerUsageDelegate _windowsNvmlDeviceGetPowerUsage;
private static WindowsNvmlDelegate _windowsNvmlInit;
@@ -45,14 +47,15 @@ namespace LibreHardwareMonitor.Interop
// windows standard search order for applications. This will
// help installations that either have the library in
// %windir%/system32 or provide their own library
WindowsDll = Kernel32.LoadLibrary("nvidiaMl.dll");
WindowsDll = Kernel32.LoadLibrary(WindowsDllName);
// If there is no dll in the path, then attempt to load it
// from program files
if (WindowsDll == IntPtr.Zero)
{
string programFilesDirectory = Environment.ExpandEnvironmentVariables("%ProgramW6432%");
string dllPath = Path.Combine(programFilesDirectory, @"NVIDIA Corporation\NVSMI\nvidiaMl.dll");
string dllPath = Path.Combine(programFilesDirectory, @"NVIDIA Corporation\NVSMI", WindowsDllName);
WindowsDll = Kernel32.LoadLibrary(dllPath);
}