function IsSupportDM(Width, Height, Bits, Freq: Cardinal): Boolean;
var
i: Integer;
dm: TDeviceMode;
begin
Result:=False;
i:=0;
while EnumDisplaySettings(Nil,i,dm) do
begin
with dm do
begin
if (dmPelsWidth=Width) and (dmPelsHeight=Height) and (dmBitsPerPel=Bits) and (dmDisplayFrequency=Freq) then
begin
Result:=True;
break;
end;
end;
Inc(i);
end;
end;
function SetDisplaySettings(Width,Height,Bits,Freq: Integer): Boolean;
var
dm: TDeviceMode;
begin
Result:=False;
if not IsSupportDM(Width,Height,Bits,Freq) then
begin
MsgBox(Format('您的显示器不支持 %dX%dX%dX%d 模式! ',[Width,Height,Bits,Freq]));
Exit;
end;
EnumDisplaySettings(nil, 0, dm);
with dm do
begin
dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL or DM_DISPLAYFREQUENCY;
dmPelsWidth:=Width;
dmPelsHeight:=Height;
dmBitsPerPel:=Bits;
dmDisplayFrequency:=Freq;
end;
ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY);
Result:=True;
end;