[電腦討論]

vb 改解析度的問題

Option Explicit
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Long

Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Const EWX_REBOOT = 2          ' 重開機
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000

Const DISP_CHANGE_SUCCESSFUL = 0
Const DISP_CHANGE_RESTART = 1
Const CDS_UPDATEREGISTRY = 1

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 DevM As DEVMODE
Private Sub Command1_Click()
    Dim i As Long
    Dim b As Long
    Dim ans As Long
    Dim a As Long

    a = EnumDisplaySettings(0, 0, DevM) 'Initial Setting

    DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
    DevM.dmPelsWidth = 1280  '設定成想要的解析度
    DevM.dmPelsHeight = 800
    b = ChangeDisplaySettings(DevM, 0) 'Changed Only this time
    If b = DISP_CHANGE_RESTART Then
        ans = MsgBox("要重開機設定才能完成,重開?", vbOKCancel)
        If ans = 1 Then
           b = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
           'after this , Will Update in Registry
           Call ExitWindowsEx(EWX_REBOOT, 0)
        End If
    Else
       If b <> DISP_CHANGE_SUCCESSFUL Then
          Call MsgBox("設定有誤", vbCritical)
       End If
    End If
End Sub
=========================================================================
這是我從網路抓到的加以應用的,只要加一個按鍵就能使用,
但我對其細節並不了解,請問有大大可以加以單步解說嗎,謝謝
喜歡這篇文章嗎?
回覆 1
您需要登入後才可以回帖 登入 | 註冊會員

本版積分規則 回覆 15 個字以上可拿獎勵,
規則詳見此

精選熱門商品

提示訊息
go_top