Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

FindNextPrinterChangeNotification and pPrinterNotifyInfo confusion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
B?rd - 26 Jan 2005 08:22 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.