第一步
设置按钮属性 xaml代码为
编写后台代码
private void Button_Click_OpenPrinterPropertie(object sender, RoutedEventArgs e)
{
printDocument = new PrintDocument();
printSettings = printDocument.PrinterSettings;
printSettings.PrinterName = TextBox_PrinterName.Text;
OpenPrinterPropertiesDialog(printSettings);
}
第二步
调用API
[DllImport("winspool.Drv", EntryPoint = "DocumentPropertiesW", SetLastError = true,
ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern int DocumentProperties(IntPtr hwnd, IntPtr hPrinter,
[MarshalAs(UnmanagedType.LPWSt