我尝试获取我们网络中的几台打印机的信息。因为我们的服务器不允许使用WMI,所以我尝试获取与Win32_PrinterDriver WMI类相同的信息,例如ConfigFile、DataFile、DependentFiles、DriverPath等等(充其量也就是通过WMI获取的所有属性)。
PrintServer ps = new PrintServer(serverName);
PrintQueueCollection printQueueCollection = ps.GetPrintQueues();
foreach (PrintQueue pq in printQueueCollection)
{
foreach (DictionaryEntry prop in pq.QueueDriver.PropertiesCollection)
{
// add props to Dictionary/Print out or sth else
}
...但是,我使用pq.QueueDriver.PropertiesCollection得到的集合只有Name属性。我现在已经在119个不同的PrintQueues上尝试过了。
有什么原因让我直接取这个名字吗?还是我在这里用错了类?
发布于 2016-02-16 00:09:59
您可以使用操作系统提供的内置Windows VB脚本来获取信息。它们的位置在这里:
C:\Windows\System32\Printing_Admin_Scripts\en-US您可以使用本文中描述的方法调用它:call VB script in c#,然后将信息输出到一个事件处理程序,并从那里获取它。
有关VB内置打印脚本及其功能的更多信息,请访问here。
https://stackoverflow.com/questions/35413758
复制相似问题