Nick Babcock 297bbff5cf Prefer load nvml from standard search order (#97)
Currently it is assumed that `nvml.dll` is located in

```
%ProgramW6432%\NVIDIA Corporation\NVSMI\nvml.dll
```

Not everyone has it installed there. Those that have the nvidia drivers
installed through windows updates will have it in in
`%WINDIR%\system32\nvml.dll` and won't have anything under the "NVSMI"
directory.

Instead of hard coding `%WINDIR%\system32\nvml.dll` as a search
location, we can load whatever `nvml.dll` appears first in the search
order:

```csharp
LoadLibrary("nvml.dll")
```

From [Standard Search Order for Desktop
Applications](https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-desktop-applications):

> 1. The directory from which the application loaded.
> 1. The system directory. Use the GetSystemDirectory function to get the path of this directory.
> 1. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
> 1. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
> 1. The current directory.
> 1. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

`%WINDIR%\system32` is the system directory and thus `nvml.dll` is loaded.

This will also allow those interested to override the `nvml.dll` by
placing their own in the current directory as LibreHM without effecting
a system installation.

Only if there is no `nvml.dll` in the search space does LibreHM fallback
to searching program files. This may technically be a breaking change
for those that have `nvml.dll` in both the search space (like
`%WINDIR%\system32\nvml.dll`) and `%ProgramW6432%\NVIDIA
Corporation\NVSMI\nvml.dll` and those files differ. I don't suspect this
to be a common occurrence.

If this is expected to be a common occurrence I can switch the logic such
that program files is checked before the standard search space, though
this would make it so one couldn't override the program files
`nvml.dll`.

Tested it and works great so far!
2019-07-09 12:59:10 +02:00
2019-06-06 11:26:22 +02:00
2019-06-06 11:26:22 +02:00
…
2018-01-27 13:37:56 +01:00
2017-08-10 18:45:21 +02:00
2018-01-28 10:12:32 +01:00
2018-05-13 17:12:24 +02:00
2018-01-27 13:37:56 +01:00
2018-05-03 15:22:45 +02:00

LibreHardwareMonitor

Build status

Libre Hardware Monitor, home of the fork of Open Hardware Monitor

We will happily accept pull requests.

You can download the latest builds here.

S
Description
ReLibreHardwareMonitor, home of the fork of LibreHardwareMonitor
Readme MPL-2.0
14 MiB
v0.1.0
Latest
2026-06-12 17:05:48 +00:00
Languages
C# 97.6%
JavaScript 2.2%
HTML 0.1%