以下是我的一个例子:
unit ScreenUnit;
interface
uses Windows;
var sx,sy:WORD;
function DynamicResolution(X, Y: word): BOOLEAN;
implementation
function DynamicResolution(X, Y: word): BOOLEAN;
var
lpDevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, lpDevMode);
if Result then
begin
lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;
sx:=lpDevMode.dmPelsWidth;
sy:=lpDevMode.dmPelsHeight;
lpDevMode.dmPelsWidth := X;
lpDevMode.dmPelsHeight := Y;
Result := ChangeDisplaySettings(lpDevMode, 0) = DISP_CHANGE_SUCCESSFUL;
end;
end;
end.