Results 1 to 6 of 6

Thread: how to check printer status!!plz help

  1. #1
    Member
    Join Date
    Feb 08
    Posts
    62

    how to check printer status!!plz help

    this is my code code and its not working...
    the value of (bool)printer.Properties["WorkOffline"].Value is always false even if the printer is online; how to fix this
    Code:
        public bool CheckMyPrinter(string printerToCheck)
    	    {
                string printerName = " ";
                // string stat = " ";
            //    ManagementScope scope = new ManagementScope(@"\root\cimv2");
             //   scope.Connect();
    
    
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM   Win32_Printer");
    
                bool IsReady = false;
                foreach (ManagementObject printer in searcher.Get())
                {
                    printerName = printer["Name"].ToString();
    
                    if (printerName.Equals(printerToCheck))
                    {
                        //stat = printer["WorkOffline"].ToString().ToLower();
                        if ((bool)printer.Properties["WorkOffline"].Value == false)
                        {
                            IsReady = true;
                        }
                    }
                }
    
                return IsReady ;
    	    }

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,562

    Re: how to check printer status!!plz help

    Thread moved from the ' UtilityBank - Tutorials' forum (which is for you to post tutorials you have written, not questions) to the 'C#' forum

  3. #3
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 06
    Location
    *Stack Trace*
    Posts
    1,512

    Re: how to check printer status!!plz help

    The property is probably not what you think it is.
    When WorkOffline is enabled, printer communication is set to a halt.
    It is not used to check the printer status, but rather a function to stop the communication.

    If that is what you thought it was, you need to review the logic here (it's actually working fine).
    WorkOffline = false, which means that the spooler is NOT working offline, so it's working online.
    Delete it. They just clutter threads anyway.

  4. #4
    Member
    Join Date
    Feb 08
    Posts
    62

    Re: how to check printer status!!plz help

    i did not get what you mean can you elaborate please

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 05
    Location
    Los Angeles, Univ. of Southern California
    Posts
    2,938

    Re: how to check printer status!!plz help

    This is what MSDN has for us:
    Quote Originally Posted by MSDN
    WorkOffline
    Data type: boolean
    Access type: Read/write
    If TRUE, you can queue print jobs on the computer when the printer is offline.

    Windows 2000 and Windows NT 4.0: This property is not supported.
    You probably need property like PrinterStatus

    Or take a look at MSDN entry on Win32_Printer Class.

    Hope it helps.
    Show Appreciation. Rate Posts.

  6. #6
    Member
    Join Date
    Feb 08
    Posts
    62

    Re: how to check printer status!!plz help

    can you give me a sample process please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •