This piece of code shows you how to find out the colour depth of the screen using the GetDeviceCaps API.
Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal hDC As Long,
ByVal nIndex As Long) As Long
Function DeviceColors(hDC As Long) As Single
Const PLANES = 14
Const BITSPIXEL = 12
DeviceColors = 2 ^ (GetDeviceCaps(hDC, PLANES) * GetDeviceCaps(hDC,
BITSPIXEL))
End Function
Private Sub cmdGetColours_click()
Dim fColours As Single
fColours = DeviceColors((hDC))
If fColours = "4.294967E+09" Then
lblColours.Caption = "Colors: " &
Colours & " -True Color (32 bit)"
ElseIf fColours = "65536" Then
lblColours.Caption = "Colors: " &
Colours & " - High Color (16 bit)"
Else
lblColours.Caption = "Colors: " &
Colours
End If
End Sub
Comments