I want to set a local printer as default in C#
I have found two ways on Google search:
- Using IWshRuntimeLibrary and IWshNetwork_Class
- [DllImport("Winspool.drv")] private static extern bool SetDefaultPrinter(string printerName);
I found #1 in VB on http://social.msdn.microsoft.com/Forums/vstudio/en-US/1ed0f29a-a5ff-4328-9c0f-f431f75fccbc/set-defualt-printer?forum=vbgeneral
Its C# Code:
new IWshRuntimeLibrary.IWshNetwork_Class().SetDefaultPrinter(printerName)
So, #1 is a COM interop call. #2 is a straightforward dll call.
I have tried both and both work fine. So, which on should I use? Do I need to install a separate library (on client's machine) for #1 ?