473,883 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending file to parallel port printer

Hi, i have trying to send a PCL file to a printer using the following codes,
but the printer would normally hang for a long time after i have send the
command, and i do not know what wrong with it, this are ample code i found in
msdn, and yet it could not work, pls advise

Thanks

Public Function PrintChunkParal lel(ByVal lPort As Long, ByVal Chunk As
String) As Long
'currently only for LPT1 only
Dim lBytestoWrite, lBytesWritten As Long
Dim x, y As Integer
Dim Success As Boolean
Dim hParallelPort As IntPtr
Dim Buffer() As Byte
Dim lStart As Long = 0
Dim MyDCB As DCB
Dim MyCommTimeouts As COMMTIMEOUTS

' Declare variables to use for encoding.
Dim oEncoder As New System.Text.ASC IIEncoding
Dim oEnc As System.Text.Enc oding = oEncoder.GetEnc oding(1252)

' Convert String to Byte().
Buffer = oEnc.GetBytes(C hunk)

hParallelPort = CreateFile("LPT 1", GENERIC_READ Or GENERIC_WRITE, 0,
IntPtr.Zero, _
OPEN_EXISTING, FILE_ATTRIBUTE_ NORMAL, IntPtr.Zero)

Success = GetCommState(hP arallelPort, MyDCB)
' Modify the properties of MyDCB as appropriate.
' WARNING: Make sure to modify the properties in accordance with
their supported values.
MyDCB.BaudRate = 9600
MyDCB.ByteSize = 8
MyDCB.Parity = NOPARITY
MyDCB.StopBits = ONESTOPBIT
' Reconfigure LPT1 based on the properties of MyDCB.
Success = SetCommState(hP arallelPort, MyDCB)

Success = GetCommTimeouts (hParallelPort, MyCommTimeouts)
' Modify the properties of MyCommTimeouts as appropriate.
' WARNING: Make sure to modify the properties in accordance with
their supported values.
MyCommTimeouts. ReadIntervalTim eout = 0
MyCommTimeouts. ReadTotalTimeou tConstant = 0
MyCommTimeouts. ReadTotalTimeou tMultiplier = 0
MyCommTimeouts. WriteTotalTimeo utConstant = 0
MyCommTimeouts. WriteTotalTimeo utMultiplier = 0
' Reconfigure the time-out settings, based on the properties of
MyCommTimeouts.
Success = SetCommTimeouts (hParallelPort, MyCommTimeouts)

lBytestoWrite = Len(Chunk)

Success = WriteFile(hPara llelPort, Buffer, lBytestoWrite,
lBytesWritten, IntPtr.Zero)
'retest this portion of the codes

Application.DoE vents()
Success = CloseHandle(hPa rallelPort)
Do
Success = WriteFile(hPara llelPort, Buffer, lBytestoWrite,
lBytesWritten, IntPtr.Zero)

If lBytesWritten <= 0 Then
If lStart = 0 Then
lStart = Timer
ElseIf Math.Abs(lStart - Timer) >= 3600 Or CancelFlag = True
Then
PrintChunkParal lel = -1
Exit Function
End If
Else
lStart = 0
End If
lBytestoWrite = lBytestoWrite - lBytesWritten
Application.DoE vents()
Loop While lBytestoWrite > 0
PrintChunkParal lel = lBytesWritten

End Function
Nov 21 '05 #1
0 1223

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
16724
by: Chuck Rittersdorf | last post by:
Hi There I am having a problem using the win32 API from VB6. I am trying to send a command string to a printer(zebra TLP 2742) on LPT1 using the folowing API functions CreateFile and WriteFile I have written C code which works fine, just the VB translation/port
4
3584
by: David | last post by:
I'm wondering if python is capable of fairly precise timing and also sending data out the parallel port. For example ; making a 7.5 KHz square wave come out of one of the data pins on the printer port. I've tried to help myself with this one but searching in the "Python Library Reference" that installed with my version, yielded nothing on the subject of either timing or parallel port.
2
1993
by: Carlos Pezzotta | last post by:
Hi guys, I have to develop an application to capture the "printed" data from another machine. I have a specialized hardware (not a computer) that has only a parallel port (Centronics-SPP) connected to a printer. I think the only way to capture the information that the system send to printer is connecting a computer to this parallel port and pretend to be a printer. So, the
12
8642
by: david.brown.0 | last post by:
I'm trying to make a Java program access a parallel port. Java's comm API does not provide me with the control I need. I need to be able to write to the data and control pins and read the status pins. Any Java people know a good solution? I'm trying to use JNI and create my own library, but building the library gives me these errors: ld: warning: cannot find entry symbol _start; defaulting to 0000000008048094 ParallelPort.o: In...
23
4166
by: Marco | last post by:
Could anyone please tell me why the program has the following error? I copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm ///////////////////////////////////////////////////////////////////// #include <dos.h> #include <string.h> #include <stdio.h> #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
4
3290
by: Hector M Banda | last post by:
Hi all, How can I send chr(7) thru VB2005 using the parallel port? BTW This is for a POS system. Thanks, -hb
2
4469
by: hari | last post by:
Hi all, I need to automate printer command testing, prinetr supports parallel/ serial/USB.How can i send the commands from python to printer. I have got pyparallel, as am new to python, no idea how to work on it. Please give some tips,The comamnd to be sent to the printer is hex data "1B 40".please give a example,it will be grateful.
0
2894
by: Charles Crawford | last post by:
Hi, This apparently is a common problem and I've yet to read a solution that actually works for my specific situation. I have a Zebra RW220 printer that I connect to via Bluetooth connection mapped to a serial port. The application I'm writing runs on a Windows Mobile 5 device, so there's no built in printer support and I have to use a serial port. When I try to write the zpl code to the serial port, the printer simply prints the code...
0
3799
by: =?Utf-8?B?Q2hhcmxpZQ==?= | last post by:
Hi, This apparently is a common problem and I've yet to read a solution that actually works for my specific situation. I have a Zebra RW220 printer that I connect to via Bluetooth connection mapped to a serial port. The application I'm writing runs on a Windows Mobile 5 device, so there's no built in printer support and I have to use a serial port.
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10745
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10848
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10417
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7972
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5798
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5992
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.