Question:
Hello I am trying to get GPU temps for a nividia gtx 980 using Delphi,
I have seen the C++ question and his solution was not to use nvcpl.dll,
I dont think this is the correct solution as nivida have a full document stating how to deal with there API(See Below).
Details:
I am using Delphi XE7 and run windows 8.1 64bit, I also compiled
code as 64bit delphi application(to able to use loadlibrary), which brings
me to think maybe Delphi types have changed when compiling x64 applications.
I have also tried using stdcall without success and diffrent types and point types.UINT Integer Dword Cardinal Int32 PDWORD DWORD_PTR
without success, hopefully someone could explain why.
Issue:
The call to "NvCplGetThermalSettings" is always returning false.
Refference:
Nvidia nvcpl.dll API manual <--- Page 64
C++ Stackoverflow Question Similar
Thanks for looking....
{
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;