【发布时间】:2014-10-29 03:47:26
【问题描述】:
我需要在我的笔记本电脑上找到已安装打印机的 IP 地址。我在不同的位置和网络之间移动我的笔记本电脑。每个网络都有自己的一组 IP 地址。笔记本电脑的每个位置都安装了不同的打印机,所有连接都是无线进行的。
在使用以下代码 (.net 4.0) 时,QueuePort.Name 返回:
WSD-27e3f972-cdc7-459d-b0c1-20e8410fb1db.0032 和
192.168.1.12_1
由于这些是网络打印机,我假设它们必须解析为真实的 IP 地址??
我哪里错了?或者,还有更好的方法? 非常感谢任何帮助。
IEnumerable<Printer> GetLocalPrinters()
{
EnumeratedPrintQueueTypes[] enumerationFlags = { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections };
LocalPrintServer printServer = new LocalPrintServer();
var x = printServer.GetPrintQueues(enumerationFlags).Select(y =>
new Printer
{
Fullname = y.FullName,
QueuePortName = y.QueuePort.Name,
Location = y.Location
})
.OrderBy( z => z.QueuePortName);
return x;
}
【问题讨论】:
标签: c# printing .net-4.0 ip-address network-printers