Posts

Showing posts with the label PrintDocument

One small thing about printers and Windows

Last night I coded a project in C#. Its function is to list all printers that connect to a PC and make the default printer print. Print documents are images. I 've never worked in that kind of work so I did googling and got some tuts. The tuts said: "Honey, just create a PrintDocument object, the fresh-created one contains a list and first element is the default printer." I believe them, I did as they told without testing and delivered to my customer. Bullsh!t, it is ENTIRELY not true. I had to be back to traditional way, access the system and read some info blah blah. You should know that I wrote a small e-book about WMI, surely I used this tool. The WMI code to get the name of default printer in Windows OS is here :         public string GetDefaultPrinterName()         {             var query = new ObjectQuery("SELECT * FROM Win32_Printer");  ...