Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
I want to find wheather printer is connected or not in client computer,
for this i have written code as
 
  ManagementScope scope = new ManagementScope("\\root\\cimv2");
 
                scope.Connect();
 
                // Select Printers from WMI Object Collections
 
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
 
                string printerName = "";
 
                foreach (ManagementObject printer in searcher.Get())
                {
 
                    printerName = printer["Name"].ToString().ToLower();
 

                    if (printerName.Contains("citizen"))
                    {
                      
                        // Console.WriteLine("Printer = " + printer["Name"]);
 
                        if (printer["WorkOffline"].ToString().ToLower().Equals("true"))
                        {
 
                            // printer is offline by user
 
                            // Console.WriteLine("Your Plug-N-Play printer is not connected.");
                       
                        }
 
                        else
                        {
                        
                            // printer is not offline
 
                            Console.WriteLine("Your Plug-N-Play printer is connected.");
 
                        }
                    }
                    else
                    {
 
                       
 
                    }
 
                }
 
 
The code above is giving me status of printer of the server where my code is hosted,But i want the status of printer of client pc.
Posted 27-Jan-13 17:42pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Take a look at the printer["Local"] property.
 
If it is True then is a Local printer, if not is a network printer.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 150
2 ChauhanAjay 120
3 BotCar 105
4 Dave Kreskowiak 100
0 Sergey Alexandrovich Kryukov 9,056
1 OriginalGriff 8,041
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100