VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 建立你自己的浏览器-打印设置
发表评论(0)作者:Soma Sundaram, 平台:VB6.0+Win98, 阅读:11119, 日期:2001-04-28
Print Setup

Insert these declarations into your form declaration section

Private Declare Function PrinterProperties Lib “winspool.drv” _
(ByVal hWnd As Long, ByVal hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib “winspool.drv” _
Alias “OpenPrinterA” (ByVal pPrinterName As String, _
phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long

Private Declare Function ClosePrinter Lib “winspool.drv” _
(ByVal hPrinter As Long) As Long
Private Type PRINTER_DEFAULTS
pDatatype As Long ‘ String
pDevMode As Long
pDesiredAccess As Long
End Type
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8
Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _
PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)

Then Insert these coding into your Click Event:

On Error Resume Next
Dim retval As Long, hPrinter As Long
Dim PD As PRINTER_DEFAULTS
PD.pDatatype = 0
PD.pDesiredAccess = STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_USE
PD.pDevMode = 0
retval = OpenPrinter(Printer.DeviceName, hPrinter, PD)
If retval = 0 Then
MsgBox “Printer Not Found”
Else
retval = PrinterProperties(Me.hWnd, hPrinter) retval = ClosePrinter(hPrinter)
End If