我正在尝试从Windows 8.1 SDK中移植GetProcessDPIAwareness
。但是,当我尝试启动此程序时,它只会因错误而崩溃:
system exception (code 0xc0000409) at 0x77929990'
该功能存在于shcore.dll
中。我正在运行Windows 8.1
所以它应该可以工作,但事实并非如此。
program Test;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Winapi.Windows;
const
shcore = 'shcore.dll';
type
HANDLE = THandle;
PROCESS_DPI_AWARENESS = (
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
);
function GetProcessDPIAwareness(
{_In_} hprocess: HANDLE;
{_Out_} out value: PROCESS_DPI_AWARENESS
): HRESULT; WINAPI; external name 'GetProcessDPIAwareness';
var
DPI: PROCESS_DPI_AWARENESS;
begin
GetProcessDPIAwareness(0, DPI); // crashes here
ReadLn;
end.
答案 0 :(得分:3)
将dll名称添加到外部声明后,代码实际编译。然后你只需要遵循TLama给出的建议并使用正确的程序名称:
function GetProcessDpiAwareness(
{_In_} hprocess: HANDLE;
{_Out_} out value: PROCESS_DPI_AWARENESS
): HRESULT; WINAPI; external shcore;