private void
FindAllPrinters()
           {
               string[] wantedProps = { "name",
"servername",
"printername",
                                          "drivername",
"shortservername",
"location"
};
               var ds = new DirectorySearcher { Filter = "(objectClass=printqueue)"
};
               foreach (SearchResult sr in ds.FindAll())
               {
                   Debug.WriteLine(sr.Path);
                   ResultPropertyCollection rpc =
sr.Properties;
                   // use rpc.PropertyNames instead of wantedProps
if you want to
                   // know more about the printers than is provided
below
                   foreach (string property in wantedProps)
                   {
                       foreach (object value in rpc[property])
                           Debug.WriteLine(string.Format("\t{0}: {1}", property, value));
                   }
               }
           }
 
 
No comments:
Post a Comment