IntPtr CreatePrinterDC(ref PAGESETUPDLGSTRUCT lppsd) { // Create managed structure for DEVNAMES DEVNAMES dn = new DEVNAMES(); Marshal.PtrToStructure(lppsd.hDevNames, dn); // Get base address of native structure int iBase = (int)lppsd.hDevNames; // Get pointer to driver name. IntPtr iptrDriver = (IntPtr)(iBase + dn.wDriverOffset); string strDriver = Marshal.PtrToStringUni(iptrDriver); // Get pointer to device name. IntPtr iptrDevice = (IntPtr)(iBase + dn.wDeviceOffset); string strDevice = Marshal.PtrToStringUni(iptrDevice); // Get pointer to output port. IntPtr iptrOutput = (IntPtr)(iBase + dn.wOutputOffset); string strOutput = Marshal.PtrToStringUni(iptrOutput); IntPtr hdc = CreateDC(iptrDriver, iptrDevice, iptrOutput, lppsd.hDevMode); return(hdc); }
void InitDlgStruct( ref PAGESETUPDLGSTRUCT psd, IntPtr hwndParent) { psd.lStructSize = Marshal.SizeOf(psd); psd.Flags = 0; psd.hwndOwner = hwndParent; }
void Close(ref PAGESETUPDLGSTRUCT lppsd) { if (lppsd.hDevMode != IntPtr.Zero) { NativeHeap.LocalFree(lppsd.hDevMode); } if (lppsd.hDevNames != IntPtr.Zero) { NativeHeap.LocalFree(lppsd.hDevNames); } }
string QueryOutputPort(ref PAGESETUPDLGSTRUCT lppsd) { // Create managed structure for DEVNAMES DEVNAMES dn = new DEVNAMES(); Marshal.PtrToStructure(lppsd.hDevNames, dn); // Get base address of native structure int iBase = (int)lppsd.hDevNames; // Get pointer to output port. IntPtr iptrOutput = new IntPtr(iBase + dn.wOutputOffset); string strOutput = Marshal.PtrToStringUni(iptrOutput); return(strOutput); }
int ShowDialog(ref PAGESETUPDLGSTRUCT psd) { return(PageSetupDlgW(ref psd)); }
int PageSetupDlgW(ref PAGESETUPDLGSTRUCT lppsd);