View Single Post
Old 06-08-2007   #1 (permalink)
Mark Rae


 
 

Getting the default printer in 64-bit Vista

Hi,

I have used the code below to return the default printer in 32-bit WinXP
Pro, but now that I am running 64-bit Vista Business I'm getting an error:

using System.Drawing.Printing;

using (PrintDocument objPrintDocument = new PrintDocument())
{
string strDefaultPrinter =
objPrintDocument.PrinterSettings.PrinterName;
}

The error message is: "No printers are installed." and which seems to come
from a method called HdevmodeInternal

However, I have several printers installed, and the default printer is an
old HP LaserJet 5.

Does the above code not work on 64-bit Vista? The app in question is
compiled for x86...

Would I be better off using WMI to return the name of the default printer?

I've tried to find a solution in Google and MSDN, but haven't had much
luck...

Any assistance gratefully received.


--
http://www.markrae.net

My System SpecsSystem Spec