winform 如何获取局域网中所有打印机的状态?

Binea 2011-09-07 09:06:41
winform 如何获取局域网中所有打印机的状态? 不是直连 就是通过网络共享的 能否获得该打印机的所有资源?
...全文
209 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Binea 2011-09-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 sensenyuan 的回复:]

C# code
ManagementObjectSearcher MgmtSearcher;

//Perform the search for printers and return the listing as a collection
MgmtSearcher = new ManagementObjectSearcher("Select * from Win32_Printer");
M……
[/Quote]无语。。。。没人回答 只能给你了
sensenyuan 2011-09-09
  • 打赏
  • 举报
回复
ManagementObjectSearcher MgmtSearcher;

//Perform the search for printers and return the listing as a collection
MgmtSearcher = new ManagementObjectSearcher("Select * from Win32_Printer");
MgmtCollection = MgmtSearcher.Get();

foreach (ManagementObject objWMI in MgmtCollection)
{

string name = objWMI["Name"].ToString().ToLower();

if (name.Equals(printerName.ToLower()))
{

int state = Int32.Parse(objWMI["ExtendedPrinterStatus"].ToString());
if ((state == 1) || //Other
(state == 2) || //Unknown
(state == 7) || //Offline
(state == 9) || //error
(state == 11) //Not Available
)
{
throw new ApplicationException("hope you are finally offline");
}

state = Int32.Parse(objWMI["DetectedErrorState"].ToString());
if (state != 2) //No error
{
throw new ApplicationException("hope you are finally offline");
}

}

}


Binea 2011-09-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 dongjianhua520520 的回复:]

介个应该是可以实现的吧。。。。不太懂。
[/Quote]

不知道能不能,直连的都是可以弄到!!局域网的就不会了!
dongjianhua520520 2011-09-08
  • 打赏
  • 举报
回复
介个应该是可以实现的吧。。。。不太懂。
Binea 2011-09-08
  • 打赏
  • 举报
回复
没人啊????

111,095

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧