熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

VB.NET設置屏幕分辨率、顏色位數、刷新率 實例代碼

2013-11-13 10:43:24  來源: .NET編程 
這篇文章介紹了VBNET設置屏幕分辨率顏色位數刷新率 實例代碼有需要的朋友可以參考一下   復制代碼 代碼如下:

  
Private Declare Function GetDeviceCaps Lib "gdi" (ByVal hdc As Long ByVal nIndex As Long) As Long
Private Declare Function ChangeDisplaySettings Lib "user" Alias "ChangeDisplaySettingsA" (lpDevMode As Any ByVal dwflags As Long) As Long
Private Const CCDEVICENAME As Long =
Private Const CCFORMNAME As Long =
Private Const DM_BITSPERPEL As Long = &H
Private Const DM_PELSWIDTH As Long = &H
Private Const DM_PELSHEIGHT As Long = &H
Private Const DM_DISPLAYFLAGS As Long = &H
Private Const DM_DISPLAYFREQUENCY = &H
Private Const CDS_FORCE As Long = &H
Private Const BITSPIXEL As Long =
Private Const HORZRES As Long =
Private Const VERTRES As Long =
Private Const VREFRESH =
Private Type DEVMODE
   dmDeviceName      As String * CCDEVICENAME
   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 * CCFORMNAME
   dmUnusedPadding   As Integer
   dmBitsPerPel      As Integer
   dmPelsWidth       As Long
   dmPelsHeight      As Long
   dmDisplayFlags    As Long
   dmDisplayFrequency As Long
End Type
Private Sub cmdChangeDesktopMode_Click()
    Dim DM As DEVMODE
    With DM
       dmPelsWidth = CInt(txtNewWidthText)
       dmPelsHeight = CInt(txtNewHeightText)
       dmBitsPerPel = CInt(txtNewColorText)
       dmDisplayFrequency = CInt(txtNewFreqText)
       dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY
       dmSize = LenB(DM)
    End With
    If ChangeDisplaySettings(DM CDS_FORCE) <> Then
        MsgBox "錯誤!不支持此模式!"
    End If
End Sub
Private Sub Form_Load()
   txtOldWidthText = GetDeviceCaps(Mehdc HORZRES)
   txtOldHeightText = GetDeviceCaps(Mehdc VERTRES)
   txtOldColorText = GetDeviceCaps(Mehdc BITSPIXEL)
   txtOldFreqText = GetDeviceCaps(Mehdc VREFRESH)
End Sub


From:http://tw.wingwit.com/Article/program/net/201311/14378.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.