
28/08/2008, 14:48
|
| | Fecha de Ingreso: abril-2008
Mensajes: 23
Antigüedad: 16 años, 11 meses Puntos: 0 | |
Respuesta: Abrir cajon mira que ya logre que ejecutara el if pero igual no abre el cajon...el puerto es Com3
mi impresora esta conectada a mi equipo por una cable de usb a paralelo...la parte usb va al computador y el paralelo a la impresora..la verdad no se si ese es el puerto correcto..pero alli te envio el codigo completo
Public Structure SECURITY_ATTRIBUTES
Private nLength As Integer
Private lpSecurityDescriptor As Integer
Private bInheritHandle As Integer
End Structure
Dim SA As SECURITY_ATTRIBUTES
Dim outFile As FileStream
Dim Safe As Microsoft.Win32.SafeHandles.SafeFileHandle
Public LPTPORT As String
Public hPort As Integer
Public hPortP As IntPtr
Public retval As Integer
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_WRITE = &H2
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
Sub Abrir()
LPTPORT = "Com3"
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'Convierte Integer to IntPtr
Safe = New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)
If Not Safe.IsInvalid Then
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)
Dim fw As New StreamWriter(outFile)
fw.AutoFlush = True
'fw.WriteLine(Chr(27) & Chr(112) & 0) 'Genérico Epson
'fw.WriteLine(Chr(27) & Chr(112) & Chr(48) & Chr(55) & Chr(121))
fw.WriteLine(Chr(&H1B) & "p" & Chr(0) & Chr(100) & Chr(250))
fw.Close()
End If
CloseHandle(hPort)
End Sub
LA SUB RUTINA ABRIR LA COLOCO DENTRO DE...
Private Sub PrintFactura_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintFactura.PrintPage
DESPUES DE IMPRIMIR LA FACTURA..LA VERDAD NO SE QUE ESTA MAL...Y YA NO SE QUE HACER... |