如何打开打印机属性对话框
wzg3k 2012-03-14 04:42:43 采用下面的代码可以打开打印机属性对话框,但是用户在该对话框中进行了设定后,新的设定值并没有保存到系统中。如何才能保存用户的设定阿?
string printerName = _document.PrinterSettings.PrinterName;
if (printerName != null && printerName.Length > 0)
{
IntPtr pPrinter = IntPtr.Zero;
IntPtr pDevModeOutput = IntPtr.Zero;
IntPtr pDevModeInput = IntPtr.Zero;
IntPtr nullPointer = IntPtr.Zero;
OpenPrinter(printerName, ref pPrinter, ref nullPointer);
int iNeeded = DocumentProperties(this.Handle, pPrinter, printerName, ref pDevModeOutput, ref pDevModeInput, 0);
pDevModeOutput = System.Runtime.InteropServices.Marshal.AllocHGlobal(iNeeded);
DocumentProperties(this.Handle, pPrinter, printerName, ref pDevModeOutput, ref pDevModeInput, 4);
ClosePrinter(pPrinter);
}