I'm trying to write application run as service in vb6.

I have two barcode printers (ZEBRA) with print servers connected to centronics port (D-LINK DP-301P+).
In my service i connect to SQL server and get information about destination printer and source code (ZPL) to print.
Now i must send my ZPL code to the printer.

Everything works fine when I save ZPL to file, map TCP to LPT1 and copy/print FILE to this port like this:

net use LPT1: \\100.0.0.1\myport1
copy C:\test1.txt lpt1: /b

or:

objNetwork.AddPrinterConnection("LPT1:", "\\100.0.0.1\myport1", True) 
...
Open "C:\test1.txt" For Binary As #1
Open "LPT1:" For Binary As #2
...

But i don't want to SAVE my ZPL code string to FILE,
i want to connect to my Print Server and Send my ZPL CODE to print.
I Need get some STATUS after operation - success or not - because i have to delete my printed label (or not) from SQL Table.
How to send data to print server? (Winsock.SendData ??)
Do i need Ascii to binary conversion or byte array?
How to check Job status?

Can someone help me?

Tom

Recommended Answers

All 2 Replies

Hmmm, I think the mscomm control handles both serial and parallel communications... but seeing that this is a network printer, and you are mapping it, it complicates things some. If the second code that you posted works (ie: using Open "c:\test1.txt" for Binary as #1) then why not simply save the code that you write to the file into like, a byte array (instead of the hard-drive), and then open LPT1 like you do, and just write the array in a loop or such to the printer. When you are done sending the data, just redim the byte array, and redim it again for a new ZPL.

Hmmm, I think the mscomm control handles both serial and parallel communications... but seeing that this is a network printer, and you are mapping it, it complicates things some. If the second code that you posted works (ie: using Open "c:\test1.txt" for Binary as #1) then why not simply save the code that you write to the file into like, a byte array (instead of the hard-drive), and then open LPT1 like you do, and just write the array in a loop or such to the printer. When you are done sending the data, just redim the byte array, and redim it again for a new ZPL.

Yes, I know, but what is the state after print (success or not)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.