Jo, das fehlende
stdcall;
ist die Ursache, wie KodeZwerg skizziert hat.
Delphi-Quellcode:
program Project5;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Winapi.Windows;
function PowerGetActiveScheme(UserRootPowerKey: HKEY;
var ActivePolicyGuid: PGUID): DWORD;
stdcall;
external '
PowrProf.dll'
name '
PowerGetActiveScheme';
var
ActivePolicyGuidPtr: PGUID;
res: DWORD;
begin
try
ActivePolicyGuidPtr :=
nil;
res := PowerGetActiveScheme(0, ActivePolicyGuidPtr);
if (res = ERROR_SUCCESS)
and Assigned(ActivePolicyGuidPtr)
then
begin
Writeln('
Active Power Scheme GUID: ', TGUID(ActivePolicyGuidPtr^).ToString);
LocalFree(ActivePolicyGuidPtr);
end;
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
Readln;
end.
Ergibt bei mir:
Code:
Active Power Scheme
GUID: {381B4222-F694-41F0-9685-FF5BB260DF2E}