NvCplGetThermalSettings返回false

时间:2015-03-25 10:05:13

标签: delphi gpu nvidia delphi-xe7

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

详细信息:
我正在使用Delphi XE7并运行Windows 8.1 64位,我也编译过 代码为64bit delphi应用程序(能够使用loadlibrary),它带来了 我想在编译x64应用程序时可能已经改变了Delphi类型。 我也试过使用stdcall但没有成功和不同的类型和点类型.UINT Integer Dword Cardinal Int32 PDWORD DWORD_PTR 没有成功,希望有人可以解释原因。

问题:
对“NvCplGetThermalSettings”的调用总是返回false。

REFFERENCE:
Nvidia nvcpl.dll API manual< --- Page 64
C++ Stackoverflow Question Similar

感谢您寻找......

{
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;

0 个答案:

没有答案