Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to send a binary file to a printer within a C++ program. Is there a way other than the 'system lpr' method? Currently I open a printer as a shared printer (\\computer-name\share-name) and this works ok, but is somewhat cumbersome when printers are added or changed. Looking for a way I can display the available printers, have the user select one, and then send the files to the selected printer.
Posted
Updated 12-Jun-10 22:25pm
v4

I found this link[^] which suggests that there was a method in the days of Win-95/NT, but I cannot be sure that it still works now; perhaps still worth investigating.
 
Share this answer
 
Comments
xmikexhx 14-Jun-10 21:18pm    
Thanks, exactly what I was looking for. Tested concept within my code and it works perfectly. Thanks again.
Use the PrintDlgEx API to show the Print dialog.
Here the user can select the printer of choice and also set its various properties.
After the user selects a printer to print, the PRINTDLGEX structure parameter to PrintDlgEx will contain a device context handle to the selected printer in its hDC member.
Printing to the selected printer is then just a matter of drawing to that printer device context.
 
Share this answer
 
Comments
xmikexhx 13-Jun-10 10:37am    
Thanks, I will try the PrintDlgEx method. However, I am concerned that the file will be corrupted by the windows driver. The files I send to a printer must be a bit for bit transfer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900