My PC is connected to a LAN and I want to get all the printers in the network to which I connected.
I tried PrinterSettings.InstalledPrinters
in my code. It returns the printer that I had configured in my computer.Actually there are 2 more printers connected in the network. I tried this code also,
System.Management.ObjectQuery oquery =
new System.Management.ObjectQuery("SELECT * FROM Win32_Printer");
System.Management.ManagementObjectSearcher mosearcher =
new System.Management.ManagementObjectSearcher(oquery);
System.Management.ManagementObjectCollection moc = mosearcher.Get();
foreach (ManagementObject mo in moc)
{
System.Management.PropertyDataCollection pdc = mo.Properties;
foreach (System.Management.PropertyData pd in pdc)
{
if ((bool)mo["Network"])
{
comboPrinters.Items.Add(pd.Name);
}
}
}
MessageBox.Show(p);
}
It also give the same output.I searched in many sites but couldn't find any solution. Any suggestions??
Thanks in advance.
NB: Our AD is not well maintained.