简体   繁体   English

为我的应用程序添加打印机

[英]add printer for my application

I want to add a printer for my application to the network printers list.I mean something like what Adobe PDF do. 我想为我的应用程序添加一台打印机到网络打印机列表中。我的意思类似于Adobe PDF。

I could get all printers in the network by the following code : 我可以通过以下代码获取网络中的所有打印机:

// Use the ObjectQuery to get the list of configured printers
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)
{
    lstPrinter.Items.Add(mo["Name"]);
}

I do not know what should i search to find this.please help ... 我不知道该搜索什么内容。请帮助...

See Command Line Printer Control . 请参阅命令行打印机控制 You can run this code by Procces.Start(...) : 您可以通过Procces.Start(...)运行以下代码:

rundll32.exe printui.dll,PrintUIEntry /?

and this link of Microsoft support can be useful: 并且Microsoft支持的此链接可能很有用:

If you consist on using WMI, the WMI Code Creator tool can help you. 如果您坚持使用WMI,则WMI Code Creator工具可以为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM