' Return True if the printer is a PostScript printer.
Private Function GetDriverInfo2(ByVal printer_name As _
String) As DRIVER_INFO_2
Dim h_printer As Long
Dim buf_len As Long
Dim buf() As Long
Dim driver_info As DRIVER_INFO_2
' Get the printer's handle.
If OpenPrinter(printer_name, h_printer, ByVal 0&) = 0 _
Then
MsgBox "Error opening printer " & printer_name & _
"." & vbCrLf & _
Err.Description
GetDriverInfo2 = driver_info
Exit Function
Else
' See how much space we need for the
' driver info structure with its strings.
ReDim buf(1 To 1)
GetPrinterDriver h_printer, "", 2, _
buf(1), 0, buf_len
' Get the data.
ReDim buf(1 To buf_len / 4 + 1)
If GetPrinterDriver(h_printer, "", 2, _
buf(1), buf_len, buf_len) = 0 _
Then
MsgBox "Error getting driver information for " _
& printer_name & "." & vbCrLf & _
Err.Description
GetDriverInfo2 = driver_info
ClosePrinter h_printer
Exit Function
End If
' Get the information.
driver_info.cVersion = buf(1)
driver_info.pName = StringFromPointer(buf(2), 1024)
driver_info.pEnvironment = _
StringFromPointer(buf(3), 1024)
driver_info.pDriverPath = StringFromPointer(buf(4), _
1024)
driver_info.pDataFile = StringFromPointer(buf(5), _
1024)
driver_info.pConfigFile = StringFromPointer(buf(6), _
1024)
GetDriverInfo2 = driver_info
ClosePrinter h_printer
End If
End Function
|