NvCplGetThermalSettings 返回 false

2024-04-29

问题:
您好,我正在尝试使用 Delphi 获取 nividia gtx 980 的 GPU 温度, 我看过C++问题,他的解决方案是不使用nvcpl.dll, 我认为这不是正确的解决方案,因为 nivida 有完整的文档说明如何处理 API(见下文)。

Details:
我使用的是Delphi XE7并运行windows 8.1 64位,我也编译了 代码为 64 位 delphi 应用程序(以便能够使用 loadlibrary),这带来了 我想也许 Delphi 类型在编译 x64 应用程序时发生了变化。 我也尝试使用 stdcall 但没有成功,并且类型和点类型不同。UINT Integer Dword Cardinal Int32 PDWORD DWORD_PTR 没有成功,希望有人能解释原因。

Issue:
对“NvCplGetThermalSettings”的调用始终返回 false。

参考:
Nvidia nvcpl.dll API手册 http://developer.download.nvidia.com/SDK/9.5/Samples/DEMOS/common/src/NvCpl/docs/NVControlPanel_API.pdf C++ Stackoverflow 问题类似 https://stackoverflow.com/questions/25376080/nvcplgetthermalsettings-call-to-nvcpl-dll-returns-false-c

感谢您的寻找....

{
NvCplGetThermalSettings()
Function
Prototype
BOOL CDECL NvCplGetThermalSettings
 (IN UINT nWindowsMonitorNumber,
 OUT DWORD* pdwCoreTemp,
 OUT DWORD* pdwAmbientTemp,
 OUT DWORD* pdwUpperLimit);
Parameters In UINT nWindowsMonitorNumber -- The display number shown on
 the Windows Display Properties->Settings page.
 A value of 0 indicates the current primary Windows display device.
DWORD* must be a valid pointer --
 pdwCoreTemp -- GPU temperature in degrees Celsius.
 pdwAmbientTemp -- Ambient temperature in degrees Celsius.
 pdwUpperLimit -- Upper limit of the GPU temperature specification.
Return Values True on success.
False on failure.
}

function NvidiaGpuTemp: Integer;
type
  NvCplGetThermalSettings = function(
    nWindowsMonitorNumber: UINT; 
    pdwCoreTemp, 
    pdwAmbientTemp, pdwUpperlimit: PDWORD): BOOL; cdecl;
var
  hNvcpl: Hwnd;
  GetThermalSettings: NvCplGetThermalSettings;
  dwCoreTemp, dwAmbientTemp, dwUpperlimit: DWORD;
begin
  Result := 0;


  hNvcpl := LoadLibrary('nvcpl.dll');
  if hNvcpl <> 0 then
    try
      GetThermalSettings := GetProcAddress(hNvcpl,'NvCplGetThermalSettings');
      if Assigned(GetThermalSettings) then
        If GetThermalSettings(0, Addr(dwCoreTemp), Addr(dwAmbientTemp), 
          Addr(dwUpperlimit)) then
        begin
         ShowMessage('Called Successfully');
         Result:= Integer(dwCoreTemp);
        end;
    finally
      FreeLibrary(hNvcpl);
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   ShowMessage(InttoStr(NvidiaGpuTemp));
end;

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

NvCplGetThermalSettings 返回 false 的相关文章

随机推荐