Skip to content

Printer Status

Rahul Kadu

Asked Jul 27, 2007, 9:51 PM EDT3 answers
Share
LinkedInX
Hi, I want to retreive printer status information which is connected to a computer on a network computer.I want to get info about online/offline/busy/paper out/error/printing etc. Can i get the code for this.This is very urgent for me. Also I am very new to .net.So please anybody can help me???

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    I suspect you can do this through the WMI functionality in .NET.  You'll need to perform a query on the Win32_Printer class.  Check out this article as well as this article  as well as this article on C# Corner
    0
  • 0
    Thank You Mike. But i have tried that using management class but still i am not getting the correct status. I heard like importing dll file i.e.winspool.drv would do but i am not able to do it. So please can u help me???
    0
  • Mike Gold
    0
    This is true, You can try pinvoking the Winspool Driver directly.  Also check this link on MSDN to see the available Winspool calls.  I suspect GetPrinterData will aid you in what you are trying to do.

    [DllImport("winspool.drv", CharSet=CharSet.Auto, SetLastError=true)]
    static extern uint GetPrinterData(IntPtr hPrinter, string pValueName, out uint pType, byte[] pData, uint nSize, out uint pcbNeeded);



    Best,

    -Mike
    0