Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/11/2009, 13:43
rishart
 
Fecha de Ingreso: enero-2008
Mensajes: 181
Antigüedad: 17 años, 1 mes
Puntos: 1
De acuerdo AYUDA problemas con codigo para imprimir ticket

Hola amigos buenas tardes les comento que tengo mi sistema y estoy tratando de incluir la parte de imprimir el ticket de compra el caso es que tengo este codigo pero al correrlo marca error en el vb.net 2008 este es el codigo que uso

Código:

Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_WRITE = &H2
Public LPTPORT As String
Public hPort As Integer, hPortP As IntPtr
Public retval 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

Public Structure SECURITY_ATTRIBUTES
Private nLength As Integer
Private lpSecurityDescriptor As Integer
Private bInheritHandle As Integer
End Structure

Ya despues en un boton copiamos y pegamos esto:

Dim SA As SECURITY_ATTRIBUTES
Dim outFile As FileStream
LPTPORT = "LPT1"
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE, SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort)

Dim Safe As New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write)

en la parte del

Dim Safe As New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP, True)
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write) aki se para y me dice que hay un error y dice que "IDENTIFICADOR NO VALIDO. NOMBRE DEL PARAMETRO HANDLE"
que puedo hacer para solucionar esa parte espero me puedan ayudar se los agradeceria muchisimooo porfavorr gracias