# 使用 GetDeviceCaps API

Posted by 小吴 on December 11, 1997 at 16:44:35:

In Reply to: 请指教：如何在 VB 中判断当前的显示状态 posted by 小蕾 on December 07, 1997 at 07:31:08:

使用 GetDeviceCaps API 传入 Form 的 hDC 以及 BITSPIXEL 常数即可。如下例：

Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const BITSPIXEL = 12

Private Sub Command1_Click()
Dim i
i = GetDeviceCaps(hdc, BITSPIXEL)
MsgBox 2 ^ i & " colors"
End Sub

Follow Ups: