扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
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_BITSPERPEL = &H40000 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 a As Boolean Dim i As Long Dim b As Long Dim ans As Long a = EnumDisplaySettings(0, 0, DevM) ’Initial Setting DevM.dmBitsPerPel = 8 ’设定成256色 DevM.dmFields = DM_BITSPERPEL b = ChangeDisplaySettings(DevM, 0) If b = DISP_CHANGE_RESTART Then ans = MsgBox("要重开机设定才能完成,重开?", vbOKCancel) If ans = 1 Then b = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY) Call ExitWindowsEx(EWX_REBOOT, 0) End If Else If b <> DISP_CHANGE_SUCCESSFUL Then Call MsgBox("设定有误", vbCritical) End If End If End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者