Epson C31C213A8941 Руководство пользователя - Страница 41

Просмотреть онлайн или скачать pdf Руководство пользователя для Принтер Epson C31C213A8941. Epson C31C213A8941 45 страниц. Tm printer driver

Epson C31C213A8941 Руководство пользователя

6.2.7. Using ESC/POS commands

The following example shows how you can use the Win32 API to transmit ESC/POS commands directly to the printer.
For more details, refer to the Win32 API help information.
Public Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
''Win32 API external reference definitions
Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Public Declare Function EndDocPrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Public Declare Function EndPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" _
(ByVal pPrinterName As String, phPrinter As Long, ByVal pDefault As Long) As Long
Public Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" _
(ByVal hPrinter As Long, ByVal Level As Long, pDocInfo As DOCINFO) As Long
Public Declare Function StartPagePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, _
pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long
'##### Source Code #####
Dim lhPrinter
As Long
Dim lReturn
As Long
Dim lpcWritten
As Long
Dim lDoc
As Long
Dim sWrittenData As String
Dim MyDocInfo
As DOCINFO
lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
If lReturn = 0 Then
MsgBox "Open Printer Error!"
End If
MyDocInfo.pDocName = "SAMPLE"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
''Output ESC/POS commands and the string to be displayed
sWrittenData = Chr(&H1B) + "=" + Chr(&H2)
sWrittenData = sWrittenData + Chr(&H1B) + "t" + Chr(&H0) 'Select the character code table.
sWrittenData = sWrittenData + Chr(&H1B) + "R" + Chr(&H0)
sWrittenData = sWrittenData + "SEIKO EPSON ESC/POS"
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
TITLE
EPSON
TM Printer Driver
User's Manual
'Select the peripheral device.
'Select international characters.
'String to be displayed.
SHEET
REVISION
1.61
NO
NEXT
SHEET
42
41