Set default printer

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

Hi all,

I am writing to C# program which require to change the default printer at
runtime.
I have try to use the follow code to do so :

[DllImport("WinSpool.drv",SetLastError=true)]
public static extern bool SetDefaultPrinter (string pPrinterName);

I works fine with Window 2000. However, when I try to run it in NT 4.0,
Exception is thrown. I think the above method is not applicable in NT4. Is
there any alternatives ?

Kenneth
 
Cannot SetDefaultPrinter on Windows 2000 & Win NT OS using C# 2005

I am unable to set the default printer on Windows 2000 and Win NT OS. - Err Message:"This Method is not implemented in any class" was caught by C# 2005.

Using Windows XP works fine..but on Windows 2000 and NT is not. Though I haven't tested using Vista or Win2003, but usually I will be using XP, 2000 and NT only.

Anyone willing to share how to overcome this problem, I would be very thankful. I don't want to be using a registry manipulation or programmatically changing it. ( to this "Software\Microsoft\Windows NT\CurrentVersion\Windows") ..etc .etc..

Is there any .DllImport("kernel32" or user32 .. ?? to use.

Thank You so much..
 
Ow my mistake.. I will only be using Win NT and Vista OS .. forget the Windows 2000..
Thank You.
 
Back
Top