Failed RaC Bid Leads to Suite101!

From Unsuccessful RentACoder to Top Article on Win32 Printing

© Guy Lecky-Thompson

Apr 17, 2007

Using the default printer from a Win32 app.; complete code to manage the printer, determine the print job, and print the text, all thanks to a failed RentACoder bid!


A while back, I was bidding on RentACoder for a job that involved printing from a command line application, using just the default printer. I bid way too high ($75 - let that be a lesson), but also created an entire application by way of a demonstration. I figure I can make it a bit more flexible, and sell it on, anyway.

Another byproduct of this process was that I learned a lot about Windows Printer programming. In fact, I didn't really know a whole lot before I started, and now I know just a little more. I thought I'd share the technique that I used in the demo, by writing an article about it.

The article covers the use of:

  • GetDefaultPrinter
  • CreateDC
  • StartDoc
  • EndDoc
  • StartPage
  • EndPage
  • DeleteDC

These are the functions that you will need to manage the printer. In addition, we touch on:

  • GetDeviceCaps
  • TextOut
  • DrawText

These are used to plan the print job, and actually dump out the text. It's well worth the little lesson, if you ever want to print quickly and easily, without resorting to PrintDlg.

You can find the entire article here : Win32 Default Printer Printing Sample

Any questions, start a discussion, or drop me an email.

Happy coding!


Post this Blog to facebook Add this Blog to del.icio.us! Digg this Blog furl this Blog Add this Blog to Reddit Add this Blog to Technorati Add this Blog to Newsvine Add this Blog to Windows Live Add this Blog to Yahoo Add this Blog to StumbleUpon Add this Blog to BlinkLists Add this Blog to Spurl Add this Blog to Google Add this Blog to Ask Add this Blog to Squidoo