- 生肖
- 蛇
- 性别
- 男
- 积分
- 208
- 积分
- 216
- 精华
- 0
- 阅读权限
- 30
- 注册时间
- 2012-4-28
- 最后登录
- 2012-6-1
- 帖子
- 30
- 生肖
- 蛇
- 性别
- 男
|
本帖最后由 sky_yx 于 2015-12-30 14:23 编辑
- Option Explicit
- Private Type DOCINFO
- pDocName As String
- pOutputFile As String
- pDatatype As String
- End Type
- Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
- hPrinter As Long) As Long
- Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
- hPrinter As Long) As Long
- Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
- hPrinter As Long) As Long
- Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
- "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
- ByVal pDefault As Long) As Long
- Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
- "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
- pDocInfo As DOCINFO) As Long
- Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
- hPrinter As Long) As Long
- Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
- hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
- pcWritten As Long) As Long
- Dim lhPrinter As Long
- Private Sub Command1_Click()
- Dim lReturn As Long
- Dim lpcWritten As Long
- Dim sWrittenData As String
- sWrittenData = "How's that for Magic !!!!" & vbCrLf
- lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
- Len(sWrittenData), lpcWritten)
- End Sub
- Private Sub Form_Load()
- Dim lReturn As Long
- Dim lDoc As Long
- Dim MyDocInfo As DOCINFO
- lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
- If lReturn = 0 Then
- MsgBox "The Printer Name you typed wasn't recognized."
- Exit Sub
- End If
- MyDocInfo.pDocName = "AAAAAA"
- MyDocInfo.pOutputFile = vbNullString
- MyDocInfo.pDatatype = vbNullString
- lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
- Call StartPagePrinter(lhPrinter)
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Dim lReturn As Long
- lReturn = EndPagePrinter(lhPrinter)
- lReturn = EndDocPrinter(lhPrinter)
- lReturn = ClosePrinter(lhPrinter)
- End Sub
复制代码
|
|