如何用pb实现设置显示器的分辨率
Delphi程序源代码如下:
library setscn;
uses Windows;
var NewDevMode: TDEVMODE;
function setdisplaymode(pwidth,pheight:integer):
longint;stdcall;export;
begin
With NewDevMode do
begin
dmSize := 122;
dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT ;
dmPelsWidth := pwidth ;
dmPelsHeight := pheight ;
end;
result:=ChangeDisplaySettings(NewDevMode,0);
end;
Function getscreenwidth():longint;stdcall;export;
begin
result:=GetDeviceCaps(hinstance, HORZRES);
end;
function getscreenheight():longint;stdcall;export;
begin
result:=GetDeviceCaps(hinstance, VERTSIZE);
end;
exports
setdisplaymode index 1,
getscreenwidth index 2,
getscreenheight index 3;
begin
end.
编译以上代码,生成一个名为setscn.dll的动态连接库.
然后把它拷入C:\WINDOWS\SYSTEM目录下。
在PB中Global External Functions申明
Public Function long setdisplaymode(long pwidth,long pheight) Library "setscn.dll"
Public Function long getscreenwidth() Library "setscn.dll"
Public Function long getscreenheight() Library "setscn.dll"
在你需要改变分辨率的地方加入“setdisplaymode(800,600)”或任何你要的分辨率,就可以改变了。
我在PB8中已经实验成功,如果没有办法生成setscn.dll,留个EMAIL吧,我发给你好了。