Hello,
I'm using the following snippet of code to try and get a list of all the
printers installed on this machine. I have installed some network printers
on this machine and they just won't show up! This is in a webservice method,
if that makes any differance.
Also, when I change the query to "Select * from Win32_Process" I do return
many processes, any ideas to what might be causing this?
J
ManagementObjectCollection oReturnCollection;
System.Management.ManagementScope oMs = new
System.Management.ManagementScope("root\\CIMV2");
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_Printer");
//Execute the query
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
//Get the results
oReturnCollection = oSearcher.Get();
//loop through found drives and write out info
foreach( ManagementObject oReturn in oReturnCollection )
{
// Printer name
output = output + "<printer>" + "Name : " + oReturn["Name"].ToString() +
"</printer>" ;
}