private static PrinterNotifyOptions CreatePrinterNotifyOptions()
        {
            JobNotifyField[] fields =
            {
                JobNotifyField.BytesPrinted,
                JobNotifyField.DataType,
                JobNotifyField.Document,
                JobNotifyField.DriverName,
                JobNotifyField.MachineName,
                JobNotifyField.NotifyName,
                JobNotifyField.PagesPrinted,
                JobNotifyField.Parameters,
                JobNotifyField.Parameters,
                JobNotifyField.PortName,
                JobNotifyField.Position,
                JobNotifyField.PrintProcessor,
                JobNotifyField.PrinterName,
                JobNotifyField.Priority,
                JobNotifyField.StartTime,
                JobNotifyField.Status,
                JobNotifyField.Submitted,
                JobNotifyField.Time,
                JobNotifyField.TotalBytes,
                JobNotifyField.TotalPages,
                JobNotifyField.UntilTime,
                JobNotifyField.UserName
            };

            PrinterNotifyOptionsType type = new PrinterNotifyOptionsType(NotifyType.Job, fields);

            return(new PrinterNotifyOptions(type));
        }
Beispiel #2
0
        /// <summary>
        /// Releases unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (_pTypes != IntPtr.Zero)
            {
                // pTypes likely has pointers that also need to be freed.
                int  size = Marshal.SizeOf <PrinterNotifyOptionsType>();
                long ptr  = _pTypes.ToInt64();
                for (int i = 0; i < _count; i++)
                {
                    PrinterNotifyOptionsType type = Marshal.PtrToStructure <PrinterNotifyOptionsType>(new IntPtr(ptr));
                    type.Dispose();
                    ptr += size;
                }

                Marshal.FreeCoTaskMem(_pTypes);
                _pTypes = IntPtr.Zero;
            }
        }