I'm sorry if this is a regular question, but I have found no answer
allthough I've been searching for an answer a long time now :)
I have declaration like this
[DllImport("winspool.drv",
EntryPoint="FindNextPrinterChangeNotification", SetLastError=true)]
public static extern int FindNextPrinterChangeNotification(int
hChange, out PRINTER_NOTIFY_OPTIONS pdwChange, IntPtr pvReserved, out
IntPtr ppPrinterNotifyInfo);
This is my function call
ManualResetEvent wh = (ManualResetEvent)state;
IntPtr ppPrinterNotifyInfo = IntPtr.Zero;
PRINTER_NOTIFY_OPTIONS notifyOptions;
notifyOptions.Count = 0;
notifyOptions.Flags = 1;//PRINTER_NOTIFY_OPTIONS_REFRESH
notifyOptions.Version = 2;
if ( FindNextPrinterChangeNotification(wh.Handle.ToInt32(),out
notifyOptions,IntPtr.Zero,out ptr ) != 0)
FindNextPrinterChangeNotification never returns 0, so that should
indicate it succeeds. My problems is that ppPrinterNotifyInfo doesn't
contain any data, and I can't figure out why.
Console.WriteLine(ppPrinterNotifyInfo.ToInt32()) allways prints '0' so
that should indicate that no data is allocated , right(?)
Please help me out(point me in a direction, whatever), I'm _very_
stuck :)
Thanks
Mattias Sj?gren - 26 Jan 2005 21:29 GMT
>[DllImport("winspool.drv",
>EntryPoint="FindNextPrinterChangeNotification", SetLastError=true)]
>public static extern int FindNextPrinterChangeNotification(int
>hChange, out PRINTER_NOTIFY_OPTIONS pdwChange, IntPtr pvReserved, out
>IntPtr ppPrinterNotifyInfo);
That doesn't look right, make it
public static extern bool FindNextPrinterChangeNotification(IntPtr
hChange, out uint pdwChange, ref PRINTER_NOTIFY_OPTIONS
pPrinterNotifyOptions, out IntPtr ppPrinterNotifyInfo);
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Bård - 26 Jan 2005 22:58 GMT
>>[DllImport("winspool.drv",
>>EntryPoint="FindNextPrinterChangeNotification", SetLastError=true)]
[quoted text clipped - 9 lines]
>
> Mattias
Same problem. ppPrinterNotifyInfo doesn't contain any data.
pdwChange is set, but not ppPrinterNotifyInfo.
Alltough there seem to be a problem with pPrinterNotifyOptions , when I
initialise it as above FindNextPrinterChangeNotificatio returns win32 error
6 ("Invalid reference" if I translate it to English from my native
language).
When I tested c++ code ppPrinterNotifyInfo was filled with data wether or
not I passed ppPrinterNotifyInfo as NULL.
Bård