回复 3楼 asad
Option Explicit
Private Type PRINTER_DEFAULTS
pDatatype
As String
pDevMode
As Long
DesiredAccess
As Long
End Type
Private Const PRINTER_ACCESS_ADMINISTER = &H4
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 Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long
Private hPrinter As Long
Private Sub Form_Load()
Dim pDef As PRINTER_DEFAULTS
pDef.DesiredAccess = PRINTER_ACCESS_ADMINISTER
Call OpenPrinter(Printer.DeviceName, hPrinter, pDef)
End Sub
Private Sub Form_Terminate()
Call ClosePrinter(hPrinter)
End Sub
Private Sub Command1_Click() '暂停
Const PRINTER_CONTROL_PAUSE = 1
Call SetPrinter(hPrinter, 0&, ByVal 0&, PRINTER_CONTROL_PAUSE)
End Sub
Private Sub Command2_Click() '取消暂停
Const PRINTER_CONTROL_RESUME = 2
Call SetPrinter(hPrinter, 0&, ByVal 0&, PRINTER_CONTROL_RESUME)
End Sub