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 / .NET SDK / June 2004

Tip: Looking for answers? Try searching our database.

Problem about FindNextPrinterChangeNotification

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sunny - 28 May 2004 03:23 GMT
Dear ALL:
   I'm writing a program about printer by C# now.I have read Duncan's
article about monitor printer by VB before and followed his method. I use
FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification API
to monitor printer.
   Now I'm puzzled by the FindNextPrinterChangeNotification function
.Whenever I call this method to get a pointer of PRINTER_NOTIFY_INFO , it
always return null.
   My code is:

 int phand;
 int whand;
 RegisteredWaitHandle rwh;
 ManualResetEvent wh;

 OpenPrinter("MicrosoftOffice",ref phand, 0) ; //MicrosoftOffice is my
printer name
 whand =
FindFirstPrinterChangeNotification(phand,(int)PrinterChangeNotificationGener
alFlags.PRINTER_CHANGE_JOB,0,0);
 wh = new ManualResetEvent(false);
 wh.Handle = new IntPtr(whand);
 rwh = ThreadPool.RegisterWaitForSingleObject(wh,new
WaitOrTimerCallback(PrinterNotifyWaitCallBack),wh,-1,true);

 public void PrinterNotifyWaitCallBack(object state,bool timeout)
 {
  int pdwChange=0;
  IntPtr ptr= IntPtr.Zero;

  bool next = FindNextPrinterChangeNotification(whand,ref pdwChange,0,ref
ptr); //The next is true,but the ptr always returns 0
  PRINTER_NOTIFY_INFO pni =
(PRINTER_NOTIFY_INFO)Marshal.PtrToStructure(ptr,typeof(PRINTER_NOTIFY_INFO))
; //So the pni is always null.

  FreePrinterNotifyInfo(ptr);
  MessageBox.Show("Notify");
  wh.Reset();
  rwh = ThreadPool.RegisterWaitForSingleObject(wh,new
WaitOrTimerCallback(PrinterNotifyWaitCallBack),wh,-1,true);
 }

   I know here are many experts at this field.Could anyone tell me why and
how to solve this problem? I'm crashed by it.

   Thank you very much!
rayuduk@eiqnetworks.com - 17 Jun 2004 05:50 GMT
Im also having the same problem.
If anyone solves it pls let me too know the solution.
Thank you verymuch in advance.

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.