how to print Test-page on default Printer
using C# Winform Code ?
thank\'s in advance
To generate the built-in Windows test page, you can also use p/invoke against PrintUI.dll. Here's a simple class which lets you do this:
public static class PrintTestPageHelper
{
[DllImport("printui.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern void PrintUIEntryW(IntPtr hwnd,
IntPtr hinst, string lpszCmdLine, int nCmdShow);
///
/// Print a Windows test page.
///
///
/// Format: \\Server\printer name, for example:
/// \\myserver\sap3
///
public static void Print(string printerName)
{
var printParams = string.Format(@"/k /n{0}", printerName);
PrintUIEntryW(IntPtr.Zero, IntPtr.Zero, printParams, 0);
}
}
public class Program
{
static void Main(string[] args)
{
PrintTestPageHelper.Print(@"\\printserver.code4life.com\sap3");
Console.WriteLine("Press enter to exit.");
Console.ReadLine();
}
}