Thank You very much Mattias.
Thank you once more. Your answer solves my problem.
"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:ugy6CyX$DHA.268@TK2MSFTNGP10.phx.gbl...
> Michal,
>
> >The tricky thing
> >is to get to the nested structures, that describes the print job that
> >ocurred. The question is: how can I pass ppPrinterNotifyInfo argument to
> >find these nested structures with print job details?
>
> Declare the structs something like this
>
> struct PRINTER_NOTIFY_INFO
> {
> public uint Version;
> public uint Flags;
> public uint Count;
> // Array of PRINTER_NOTIFY_INFO_DATA follows
> }
>
> struct PRINTER_NOTIFY_INFO_DATA
> {
> public ushort Type;
> public ushort Field;
> public uint Reserved;
> public uint Id;
> public uint cbBuf; // or adwData[0]
> public IntPtr pBuf; // or uint adwData[1]
> }
>
> Declare FindNextPrinterChangeNotification like this
>
> static extern bool FindNextPrinterChangeNotification(..., out IntPtr
> ppPrinterNotifyInfo);
>
> and finally call it like this
>
> IntPtr pNotifyInfo;
> if ( FindNextPrinterChangeNotification( ..., out pNotifyInfo ) ) {
> PRINTER_NOTIFY_INFO info =
> (PRINTER_NOTIFY_INFO)Marshal.PtrToStructure(
> pNotifyInfo, typeof(PRINTER_NOTIFY_INFO) );
> int pData = (int)pNotifyInfo +
> Marshal.SizeOf( typeof(PRINTER_NOTIFY_INFO) );
> PRINTER_NOTIFY_INFO_DATA[] data =
> new PRINTER_NOTIFY_INFO_DATA[info.Count];
> for ( uint i = 0; i < info.Count; i++ ) {
> data[i] = (PRINTER_NOTIFY_INFO_DATA)Marshal.PtrToStructure(
> (IntPtr)pData, typeof(PRINTER_NOTIFY_INFO_DATA) );
> pData += Marshal.SizeOf( typeof(PRINTER_NOTIFY_INFO_DATA) );
> }
> FreePrinterNotifyInfo( pNotifyInfo );
> }
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
>
http://www.msjogren.net/dotnet/ |
http://www.dotnetinterop.com > Please reply only to the newsgroup.