das hab ich in eknoris Schatzkiste gefunden, scheint aber ursprünglich für VB zu sein, sollte aber laufen :
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2000 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, _
ByVal nIndex As Long) As Long
Private Const HORZRES As Long = 8
Private Const VERTRES As Long = 10
Private Const BITSPIXEL As Long = 12
Private Const VREFRESH As Long = 116
Private Sub Command1_Click()
Dim currHRes As Long
Dim currVRes As Long
Dim currBPP As Long
Dim currVFreq As Long
Dim sBPPtype As String
Dim sFreqtype As String
'get the system settings
currHRes = GetDeviceCaps(hdc, HORZRES)
currVRes = GetDeviceCaps(hdc, VERTRES)
currBPP = GetDeviceCaps(hdc, BITSPIXEL)
currVFreq = GetDeviceCaps(hdc, VREFRESH)
'pretty up the descriptions a tad
Select Case currBPP
Case 4: sBPPtype = "(16 Color)"
Case 8: sBPPtype = "(256 Color)"
Case 16: sBPPtype = "(High Color)"
Case 24, 32: sBPPtype = "(True Color)"
End Select
Select Case currVFreq
Case 0, 1: sFreqtype = "(Hardware default)"
Case Else: sFreqtype = "(User-selected)"
End Select
Label2 = currHRes & " pixels"
Label3 = currVRes & " pixels"
Label4 = currBPP & " bits per pixel " & sBPPtype
Label5 = currVFreq & " hz " & sFreqtype
End Sub
'--end block--'
Comments
These are all the available constants from the Windows header file pertaining to display settings obtainable through GetDeviceCaps().
Option Explicit
Private Const DRIVERVERSION As Long = 0 'Device driver version
Private Const TECHNOLOGY As Long = 2 'Device classification
Private Const HORZSIZE As Long = 4 'Horizontal size in millimeters
Private Const VERTSIZE As Long = 6 'Vertical size in millimeters
Private Const HORZRES As Long = 8 'Horizontal width in pixels
Private Const VERTRES As Long = 10 'Vertical height in pixels
Private Const BITSPIXEL As Long = 12 'Number of bits per pixel
Private Const PLANES As Long = 14 'Number of planes
Private Const NUMBRUSHES As Long = 16 'Number of brushes the device has
Private Const NUMPENS As Long = 18 'Number of pens the device has
Private Const NUMMARKERS As Long = 20 'Number of markers the device has
Private Const NUMFONTS As Long = 22 'Number of fonts the device has
Private Const NUMCOLORS As Long = 24 'Number of colors the device supports
Private Const PDEVICESIZE As Long = 26 'Size required for device descriptor
Private Const CURVECAPS As Long = 28 'Curve capabilities
Private Const LINECAPS As Long = 30 'Line capabilities
Private Const POLYGONALCAPS As Long = 32 'Polygonal capabilities
Private Const TEXTCAPS As Long = 34 'Text capabilities
Private Const CLIPCAPS As Long = 36 'Clipping capabilities
Private Const RASTERCAPS As Long = 38 'Bitblt capabilities
Private Const ASPECTX As Long = 40 'Length of the X leg
Private Const ASPECTY As Long = 42 'Length of the Y leg
Private Const ASPECTXY As Long = 44 'Length of the hypotenuse
Private Const SHADEBLENDCAPS As Long = 45 'Shading and blending caps (IE5)
Private Const LOGPIXELSX As Long = 88 'Logical pixels/inch in X
Private Const LOGPIXELSY As Long = 90 'Logical pixels/inch in Y
Private Const SIZEPALETTE As Long = 104 'Number of entries in physical palette
Private Const NUMRESERVED As Long = 106 'Number of reserved entries in palette
Private Const COLORRES As Long = 108 'Actual color resolution
Private Const VREFRESH As Long = 116 'Current vertical refresh rate of the
'display device (for displays only) in Hz
Private Const DESKTOPVERTRES As Long = 117 'Horizontal width of entire desktop in pixels (NT5)
Private Const DESKTOPHORZRES As Long = 118 'Vertical height of entire desktop in pixels (NT5)
Private Const BLTALIGNMENT As Long = 119 'Preferred blt alignment
Private Sub Command1_Click()
'get the system settings
Print GetDeviceCaps(hdc, DRIVERVERSION) 'Device driver version
Print GetDeviceCaps(hdc, TECHNOLOGY) 'Device classification
Print GetDeviceCaps(hdc, HORZSIZE) 'Horizontal size in millimeters
Print GetDeviceCaps(hdc, VERTSIZE) 'Vertical size in millimeters
Print GetDeviceCaps(hdc, HORZRES) 'Horizontal width in pixels
Print GetDeviceCaps(hdc, VERTRES) 'Vertical height in pixels
Print GetDeviceCaps(hdc, BITSPIXEL) 'Number of bits per pixel
Print GetDeviceCaps(hdc, PLANES) 'Number of planes
Print GetDeviceCaps(hdc, NUMBRUSHES) 'Number of brushes the device has
Print GetDeviceCaps(hdc, NUMPENS) 'Number of pens the device has
Print GetDeviceCaps(hdc, NUMMARKERS) 'Number of markers the device has
Print GetDeviceCaps(hdc, NUMFONTS) 'Number of fonts the device has
Print GetDeviceCaps(hdc, NUMCOLORS) 'Number of colors the device supports
Print GetDeviceCaps(hdc, PDEVICESIZE) 'Size required for device descriptor
Print GetDeviceCaps(hdc, CURVECAPS) 'Curve capabilities
Print GetDeviceCaps(hdc, LINECAPS) 'Line capabilities
Print GetDeviceCaps(hdc, POLYGONALCAPS) 'Polygonal capabilities
Print GetDeviceCaps(hdc, TEXTCAPS) 'Text capabilities
Print GetDeviceCaps(hdc, CLIPCAPS) 'Clipping capabilities
Print GetDeviceCaps(hdc, RASTERCAPS) 'Bitblt capabilities
Print GetDeviceCaps(hdc, ASPECTX) 'Length of the X leg
Print GetDeviceCaps(hdc, ASPECTY) 'Length of the Y leg
Print GetDeviceCaps(hdc, ASPECTXY) 'Length of the hypotenuse
Print GetDeviceCaps(hdc, SHADEBLENDCAPS) 'Shading and blending caps (IE5)
Print GetDeviceCaps(hdc, LOGPIXELSX) 'Logical pixels/inch in X
Print GetDeviceCaps(hdc, LOGPIXELSY) 'Logical pixels/inch in Y
Print GetDeviceCaps(hdc, SIZEPALETTE) 'Number of entries in physical palette
Print GetDeviceCaps(hdc, NUMRESERVED) 'Number of reserved entries in palette
Print GetDeviceCaps(hdc, COLORRES) 'Actual color resolution
Print GetDeviceCaps(hdc, VREFRESH) 'Current vertical refresh rate of the
'display device (for displays only) in Hz
Print GetDeviceCaps(hdc, DESKTOPVERTRES) 'Horizontal width of entire desktop in pixels
Print GetDeviceCaps(hdc, DESKTOPHORZRES) 'Vertical height of entire desktop in pixels
Print GetDeviceCaps(hdc, BLTALIGNMENT) 'Preferred blt alignment
End Sub