將底下的程式碼貼入模組內,執行巨集 Show_Display_Mode 會在工作表內顯示出你的顯示卡可支援(更新率70以上、寬800像素以上、位元率16或32)的有多少種? |
Option Explicit
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, ipDevMode As Any) As Boolean
Private Type DMODE
dmDeviceName As String * 32
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 * 32
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Sub Show_Display_Mode()
Dim Dev_M As DMODE
Dim r As Long, i As Long
Dim Chk_Mode As Boolean
Cells.Clear
i = 0: r = 1
Cells(r, 1) = "寬(像素)"
Cells(r, 2) = "高(像素)"
Cells(r, 3) = "更新率"
Cells(r, 4) = "色彩(位元)"
Do
Chk_Mode = EnumDisplaySettings(0, i, Dev_M)
If Chk_Mode = False Then Exit Do
'更新率70以上、寬800像素以上、位元率16或32
If Dev_M.dmDisplayFrequency >= 70 And Dev_M.dmPelsWidth >= 800 And _
(Dev_M.dmBitsPerPel = 32 Or Dev_M.dmBitsPerPel = 16) Then
r = r + 1
Cells(r, 1) = Dev_M.dmPelsWidth
Cells(r, 2) = Dev_M.dmPelsHeight
Cells(r, 3) = Dev_M.dmDisplayFrequency
Cells(r, 4) = Dev_M.dmBitsPerPel
End If
i = i + 1
Loop
Cells(r + 1, 1) = "介面卡支援的模式共有:" & i & " 種"
Cells(r + 2, 1) = "16位元以上的模式共有:" & r - 1 & " 種"
End Sub

