首页 > 开发 > 综合 > 正文

VB6中改变屏幕的分辨率和刷新频率!!!

2024-07-21 02:21:01
字体:
来源:转载
供稿:网友
option explicit

public declare function changedisplaysettings lib "user32.dll" alias "changedisplaysettingsa" (byref lpdevmode as devmode, byval dwflags as long) as long
public declare function enumdisplaysettings lib "user32.dll" alias "enumdisplaysettingsa" (byval lpszdevicename as string, byval imodenum as long, byref lpdevmode as devmode) as long

const dm_pelsheight as long = &h100000
const dm_pelswidth as long = &h80000
const dm_bitsperpel as long = &h40000
const dm_displayfrequency as long = &h400000

const cchdevicename as long = 32
const cchformname as long = 32
const cds_test = &h4

private type devmode
dmdevicename as string * cchdevicename
dmspecversion as integer
dmdriverversion as integer
dmsize as integer
dmdriverextra as integer
dmfields as long
dmorientation as integer
dmpapersize as integer
dmpaperlength as integer
dmpaperwidth as integer
dmscale as integer
dmcopies as integer
dmdefaultsource as integer
dmprintquality as integer
dmcolor as integer
dmduplex as integer
dmyresolution as integer
dmttoption as integer
dmcollate as integer
dmformname as string * cchformname
dmunusedpadding as integer
dmbitsperpel as integer
dmpelswidth as long
dmpelsheight as long
dmdisplayflags as long
dmdisplayfrequency as long
end type

'-------------------------------------------------------------------------------------------
' lngwidth //屏幕的宽(单位象素)
' lngheight //屏幕的高(单位象素)
' intcolor //多少位颜色(e.g 16 or 32)
' lngfrequency //屏幕的刷新频率
'
'声明:
' 调用该函数时要确定所设置的值在系统所允许的设置范围内,比如系统的最大刷新频率位80,而你
' 用把lngfrequency设位85,这样将带来无法预测的后果。
'------------------------------------------------------------------------------------------
public function setdisplaymode(lngwidth as long, lngheight as long, intcolor as integer, lngfrequency as long) as long
dim newdevmode as devmode
dim lngp as long

'obtains information
enumdisplaysettings 0&, 0&, newdevmode

with newdevmode
.dmfields = dm_pelsheight or dm_pelswidth or dm_bitsperpel or dm_displayfrequency
.dmpelswidth = lngwidth
.dmpelsheight = lngheight
.dmbitsperpel = intcolor
.dmdisplayfrequency = lngfrequency
end with

setdisplaymode = changedisplaysettings(newdevmode, cds_test)
end function





发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表