The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: herge on December 12, 2005, 02:02:25 PM

Title: How Do You Send File to Printer
Post by: herge on December 12, 2005, 02:02:25 PM
Hi All:

I am trying to send a File to the printer.
I would like to write a Assembler Program
to send a file to the printer.
It's off a USB it's  a HP 845c.
Title: Re: How Do You Send File to Printer
Post by: hutch-- on December 12, 2005, 04:14:45 PM
I moved the topic to the Workshop so you would get more answers. With apologies I don't know the answer, I knew how the older stuff was done but I am not up to date with Windows only printers and later USB stuff.
Title: Re: How Do You Send File to Printer
Post by: farrier on December 12, 2005, 05:47:52 PM
herge,

What kind of file?  Plain text, HP-PCL, PostScript, or are you trying to print from a word processing program?  Each will require a different answer?  What are you trying to do?  DOS, Windows, Linux ?

farrier
Title: Re: How Do You Send File to Printer
Post by: herge on December 12, 2005, 06:04:04 PM
Hi farrier :

I will try to print ASCII text files from a Dos box
in Windows XP.
Title: Re: How Do You Send File to Printer
Post by: P1 on December 12, 2005, 07:05:58 PM
This has been discussed before.  Please use the Search feature to find what has been posted before.

As far as text files go,  I believe you can just copy them to LPT1 and your print driver does the rest.

Regards,  P1  :8)
Title: Re: How Do You Send File to Printer
Post by: farrier on December 12, 2005, 11:06:33 PM
herge,

Attached is a program I had to code to sovle a problem I had when a 15 year customer upgraded from a DOS computer network to a WinXP Pro network and their FoxPro for DOS program stopped printing reliably.  What the program does is:

Monitor a specified subdirectory for the creation and closure of a file.
Depending on the name of the newly created file, the corresponding printer is opened
The contents of the file is then sent to the printer
The file is deleted

It may be more than you need, but it contains the code needed to simply send the contents to any local or network printer without user interaction.  The version I will provide is specific to a store which uses 4 different printers.  The files created by the FoxPro program are: LABL, REPT, PB, SALES.  And each is sent to a corresponding printer.  The program is started and hiden to run in the background.

Included is also the C file provided with the WinXP Platform SDK API, RawPrint.c

P1,

You can't "copy" to a USB printer, COM and LPT ports--if present--were all set up as if the were files/file handles, available for input/output.  The USB and FireWire ports are not, as far as I could figure out, and their printers have to be handled by the print driver/server.

hth,

farrier

[attachment deleted by admin]
Title: Re: How Do You Send File to Printer
Post by: P1 on December 12, 2005, 11:21:10 PM
Quote from: farrier on December 12, 2005, 11:06:33 PMYou can't "copy" to a USB printer, COM and LPT ports--if present--were all set up as if the were files/file handles, available for input/output.  The USB and FireWire ports are not, as far as I could figure out, and their printers have to be handled by the print driver/server.
With a little help from clever software.

I could not assume his printer did not come was a capture software, but for those that don't:

http://www.andtechnologies.com/dosprint.html

We still maintain some ancient apps, that print to LPT1, but it has a USB printer installed.  Here was a solution for our problem.  You need to be Administrator to install, then after that you can bump the client down to Power User.

Regards,  P1  :8)
Title: Re: How Do You Send File to Printer
Post by: farrier on December 13, 2005, 01:28:33 AM
P1,

That looks interesting, it would have done almost everything I needed it to do!  I kinda enjoyed coding my solution, but my customer wanted it "yesterday" and now they don't even have to think about it.  I've also been able to use it in a number of other DOS and Windows setups with other software.

Thanks for the link!

farrier
Title: Re: How Do You Send File to Printer
Post by: P1 on December 13, 2005, 02:16:36 PM
Quote from: farrier on December 13, 2005, 01:28:33 AMThanks for the link!
Your welcome  :U

Programmers helping programmers.

farrier, you have helpped me a number of times by your published work and advice.  Thank You !!!   :clap:

Regards,  P1  :8)
Title: Re: How Do You Send File to Printer
Post by: MichaelW on December 14, 2005, 02:15:20 PM
With a DOS HLL this could be as simple as:
SHELL "notepad.exe /p filename.txt"
Title: Re: How Do You Send File to Printer
Post by: herge on December 14, 2005, 02:20:59 PM
Hi MichealW:

What's DOS HLL?
Looks like we are shelling to DOS?
Title: Re: How Do You Send File to Printer
Post by: MichaelW on December 14, 2005, 02:26:39 PM
A DOS High Level Language, QBasic for example.

Title: Re: How Do You Send File to Printer
Post by: herge on May 13, 2006, 01:02:38 PM
 Hi Me:

I have found some free software from:
(requires Windows 4.0, 2000, or XP - Windows 9x is not supported)
http://www.andtechnologies.com/dosprint.html

They have some thing callled DOSPRINT.
It's  a 65K Zip file.
You can actual use the Dos Print command
  after DosPrint captures LPt1!
  Copy DOSPrint.exe to the SYSTEM32 directory
Type: dosprint install
Type: net start dosprint

some Commands

DOSPrint LptX printerName   Capture LptX to printerName
DOSPRINT lptX /d      Remove Lptx capture
Dosprint status      Display capture status

Yours Truly:
Herge



[attachment deleted by admin]
Title: Re: How Do You Send File to Printer
Post by: ChrisLeslie on May 14, 2006, 06:03:42 AM
herge,

The simple way is to do as MichaelW suggested, i.e. calling notepad, from within your program, with with file that you wish to print as an argument, then simply using the notepad print menu. The advantage of that method is that you get to select your printer and font. You could also use qeditor if using masm32. If you wish to use assembler you would do thus:

.386
.model flat,stdcall
option casemap:none
      include \masm32\include\windows.inc
      include \masm32\include\masm32.inc
      include \masm32\include\kernel32.inc
      includelib \masm32\lib\masm32.lib
      includelib \masm32\lib\kernel32.lib
           
.data
    theFile db "qeditor.exe textfile.txt",0
.code

printFile proc
    invoke wshell,ADDR theFile 
    invoke ExitProcess,0
printFile endp 
     
end printFile


You will have to have qeditor and the file to print in the same folder as the program, or if not, specify the file paths as normal.

Chris
Title: Re: How Do You Send File to Printer
Post by: herge on May 14, 2006, 08:48:35 AM
 Hi Chris:

It works for me!

Thank you.