TopSat,
Its not my code and its a bit of a mess but it appears to work in VB6 under XP SP2. Hope you can make sense of it.
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Any) As Long
'CreateIC will not work; use CreateDC
'Private Declare Function CreateIC Lib "gdi32" Alias "CreateICA" (ByVal lpDriverName As String, _
ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc, ByVal nindex) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc)
Example code;
'unsuffixed variables are all longs
Dim szprinter$
' Get printer information from WIN.INI:
szprinter$ = Space$(128)
a = GetProfileString("windows", "device", "", szprinter$, 64)
a1$ = Left$(szprinter$, a) ' These lines find the commas in the text
a2 = InStr(a1$, ",") ' and strip them out.
print_device$ = Left$(a1$, a2 - 1) & Chr$(0) ' Hold printer device info
Print "Printer = ", print_device$
a3$ = Mid$(a1$, a2 + 1)
a4 = InStr(a3$, ",")
driver$ = Left$(a3$, a4 - 1) & Chr$(0) ' Hold printer driver info.
Print "Driver = ", driver$
Port$ = Mid$(a1$, a2 + a4 + 1) & Chr$(0) ' Hold printer port info.
Print "Port = ", Port$
a5 = CreateDC(driver$, print_device$, Port$, 0&)
a6 = GetDeviceCaps(a5, 0)
Print "Driver Version : "; Hex$(a6)
Print
z1 = Get_Device_Information(a5)
finished = DeleteDC(a5)
Function Get_Device_Information(hdc As Long)
a7 = GetDeviceCaps(hdc, HORZSIZE)
Print "(HORZSIZE)", , "Width in millimeters:", a7
a8 = GetDeviceCaps(hdc, VERTSIZE)
Print "(VERTSIZE)", , "Height in millimeters:", a8
a9 = GetDeviceCaps(hdc, HORZRES)
Print "(HORZRES)", , "Width in Pixels:", a9
a10 = GetDeviceCaps(hdc, VERTREZ)
Print "(VERTREZ)", , "Height in raster Lines:", a10
a11 = GetDeviceCaps(hdc, BITSPIXEL)
Print "(BITSPIXEL)", , "Color bits per Pixel:", a11
a12 = GetDeviceCaps(hdc, PLANES)
Print "(PLANES)", , "Number of Color Planes:", a12
a13 = GetDeviceCaps(hdc, NUMBRUSHES)
Print "(NUMBRUSHES)", "Number of device brushes:", a13
a14 = GetDeviceCaps(hdc, NUMPENS)
Print "(NUMPENS)", , "Number of device pens:", a14
a15 = GetDeviceCaps(hdc, NUMMARKERS)
Print "(NUMMARKERS)", "Number of device markers:", a15
a16 = GetDeviceCaps(hdc, NUMFONTS)
Print "(NUMFONTS)", "Number of device fonts:", a16
a17 = GetDeviceCaps(hdc, NUMCOLORS)
Print "(NUMCOLORS)", "Number of device colors:", a17
a18 = GetDeviceCaps(hdc, PDEVICESIZE)
Print "(PDEVICESIZE)", "Size of device structure:", a18
a19 = GetDeviceCaps(hdc, ASPECTX)
Print "(ASPECTX)", , "Relative width of pixel:", a19
a20 = GetDeviceCaps(hdc, ASPECTY)
Print "(ASPECTY)", , "Relative height of pixel:", a20
a21 = GetDeviceCaps(hdc, ASPECTXY)
Print "(ASPECTXY)", , "Relative diagonal of pixel:", a21
a22 = GetDeviceCaps(hdc, LOGPIXELSX)
Print "(LOGPIXELSX)", "Horizontal dots per inch:", a22
a23 = GetDeviceCaps(hdc, LOGPIXELSY)
Print "(LOGPIXELSY)", "Vertical dots per inch:", a23
a24 = GetDeviceCaps(hdc, SIZEPALETTE)
Print "(SIZEPALETTE)", "Number of palette entries:", a24
a25 = GetDeviceCaps(hdc, NUMRESERVED)
Print "(NUMRESERVED)", "Reserved palette entries:", a25
a26 = GetDeviceCaps(hdc, SIZEPALETTE)
Print "(SIZEPALETTE)", "Actual color resolution:", a26
End Function
regards Hugh