Tuesday, November 23, 2004

Printer name in C#

Getting the Name of the Printer attached using C# Code

Use printer admin object (prnadmin.dll)

Here is the snippet...
Dim tObjPrinter As Object

Private mObjPrintMaster As Object

Try

mObjPrintMaster = CreateObject('PrintMaster.PrintMaster.1')

tObjPrinter = CreateObject('Printer.Printer.1')

mObjPrintMaster.PrinterGet('',PrinterName , tObjPrinter)

mObjPrintMaster.DefaultPrinter = mStrPrinterName

mObjPrintMaster.PrinterSet(tObjPrinter)

Catch ex As Exception

End Try"