DELPHI 修改系统分辨率
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; OldWinKuan,OldWinGao:INTEGER; //获取当前窗体分辨率 implementation {$R *.dfm} //更改系统显示刷新频率 function ChangeDisplay(width,height:word) :BOOL ; var lpDevMode :TDEVICEMODe ; begin result := EnumDisplaySettings(Nil ,0 ,lpDEVMode) ; if result then begin lpDevmode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT ; lpdevmode.dmPelsWidth := width ; lpdevmode.dmPelsHeight := height ; result := ChangeDisplaySettings(lpdevmode ,CDS_UPDATEREGISTRY) = DISP_CHANGE_SUCCESSFUL ; end; end; {上面的代码,在2000系统下执行,刷新频率为最低,所以必改刷新频率。以下为刷新率函数} //获得当前系统显示刷新频率 {function GetDispSet():integer; var DeviceMode: TDeviceMode; begin result:=0; EnumDisplaySettings(nil, Cardinal(-1), DeviceMode); result:=DeviceMode.dmDisplayFrequency; end; //改变系统显示刷新频率 function ChangeDispSet(iFrequency:integer):integer; var DeviceMode:TDeviceMode; begin result:=0; EnumDisplaySettings(nil,Cardinal(-1), DeviceMode); DeviceMode.dmDisplayFrequency:=Cardinal(iFrequency); result:=ChangeDisplaySettings(DeviceMode,CDS_UPDATEREGISTRY); end; } procedure TForm1.FormCreate(Sender: TObject); begin OldWinKuan:=screen.Width; OldWinGao:=screen.Height; if (screen.Width <> 1280) and (screen.Height <> 1024) then Begin ChangeDisplay(1280,1024) //修改屏幕分辨率为 1280*1024 End; end; procedure TForm1.FormDestroy(Sender: TObject); begin if (screen.Width <> OldWinKuan) and (screen.Height <> OldWinGao) then Begin ChangeDisplay(OldWinKuan,OldWinGao) End; end; end.