'Interface Calls for Configuration of LPT Port with Zebra Printer
'******************************************************************************
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_WRITE = &H2
Dim LPTPORT As String
Dim hPort As Integer
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, _
ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, _
ByVal hTemplateFile As Integer) As Integer
Public Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Integer) As Integer
Dim retval As Integer
Public Structure SECURITY_ATTRIBUTES
Private nLength As Integer
Private lpSecurityDescriptor As Integer
Private bInheritHandle As Integer
End Structure
'***************************************************************************
LPTPORT = "LPT1"
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'convert Integer to IntPtr
outFile = New FileStream(hPortP, FileAccess.Write, False) 'Create FileStream using Handle
Dim fileWriter As New StreamWriter(outFile)
fileWriter.Write("^XA")
fileWriter.Write("^LH0,0")
fileWriter.Write("^LL480")
|