VB 修改分辨率(不用重启)_VB.net_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

VB 修改分辨率(不用重启)

作者:黑客防线网安VB教程基地 来源:黑客防线网安VB教程基地 浏览次数:0

本篇关键词:不用分辨率修改 
黑客防线网安网讯:将以下代码放一个模块里.Option ExplicitPublic Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (ByRef lpDevMode As DEVMODE, ByVal dwFlags A...

将以下代码放一个模块里.

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_PEDTH 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
    dmPedth 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
 
      EnumDisplaySettings 0&, 0&, NewDevmode
     
  With NewDevmode
       .dmFields = DM_PELSHEIGHT Or DM_PEDTH Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY
       .dmPedth = LngWidth
       .dmPelsHeight = LngHeight
       .dmBitsPerPel = IntColor
       .dmDisplayFrequency = LngFrequency
  End With
 
      SetDisplaymode = ChangeDisplaySettings(NewDevmode, CDS_TEST)
End Function

然后在窗体中放一个按钮

Private Sub Command1_Click()
SetDisplaymode 800, 600, 32, 85'修改为800X600,32色,85刷新率.
End Sub

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-14691-1.html
网站维护教程更新时间:2012-04-03 01:12:36  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer