Как определить разрешения и количества цветов
дисплея
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Public Const HORZRES = 8
Public Const VERTRES = 10
Public Const BITSPIXEL = 12
Public Sub GetVideoMode(ByRef Width As Long, ByRef Height As Long, ByRef Depth As Long)
Dim hDC As Long
hDC = GetDC(GetDesktopWindow())
Width = GetDeviceCaps(hDC, HORZRES)
Height = GetDeviceCaps(hDC, VERTRES)
Depth = GetDeviceCaps(hDC, BITSPIXEL)
ReleaseDC GetDesktopWindow(), hDC
End Sub
Использование:
Dim Height As Long, Width As Long, Depth As Long
GetVideoMode Width, Height, Depth
Примечание: В переменной Depth
возвращается не количество цветов, а количество
битов на один пиксель. Т.е. 16 цветам соответствует
4 бита на пиксель, 256 - 8 бит, 65536 - 16 бит и т.д.
|