function TForm1.DynamicResolution(X, Y: word): BOOLean;
var
lpDevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, lpDevMode);
if Result then
begin
lpDevMode.dmFields := DM_PELSWIDTH + DM_PELSHEIGHT;
lpDevMode.dmPelsWidth := X;
lpDevMode.dmPelsHeight := Y;
Result := ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY) = DISP_CHANGE_SUCCESSFUL;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DynamicResolution(800, 600);
end;
自己看看,主要是ChangeDisplaySettings这个API,所有的属性在TDeviceMode中