Is there a API or registry key which I can use from applications (native, Java or .Net) to check if the currently logged on user has configured a default printer?
Update: Many thanks for the answers so far! According to the KB article http://support.microsoft.com/kb/156212, the registry entry (read/write) is only documented up to Windows 2000. Is there a Win API method in newer versions for native access?
In .NET this code works for me:
public static string DefaultPrinterName()
{
string functionReturnValue = null;
System.Drawing.Printing.PrinterSettings oPS
= new System.Drawing.Printing.PrinterSettings();
try
{
functionReturnValue = oPS.PrinterName;
}
catch (System.Exception ex)
{
functionReturnValue = "";
}
finally
{
oPS = null;
}
return functionReturnValue;
}
From: http://in.answers.yahoo.com/question/index?qid=20070920032312AAsSaPx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With