1

我尝试获取有关我们网络中几台打印机的信息。因为在我们的服务器上不允许使用 WMI,所以我尝试获取与Win32_PrinterDriverWMI 类相同的信息,例如、 、ConfigFile等等DataFile(我最多可以通过 WMI 获取所有属性)。DependentFilesDriverPath

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
    }
...

但是,我得到的 Collectionpq.QueueDriver.PropertiesCollection只有该Name属性。我现在已经在 119 个不同的 PrintQueue 上尝试过了。

我为什么要得到这个名字是有原因的吗?还是我在这里使用了错误的课程?

4

1 回答 1

0

您可以使用操作系统提供的内置 Windows VB 脚本获取信息。他们的位置在这里:

C:\Windows\System32\Printing_Admin_Scripts\en-US

您可以使用本文中描述的方法调用它:在 c# 中调用 VB 脚本,然后将信息通过管道输出到事件处理程序,然后从那里获取它。

有关内置 VB 打印脚本及其功能的更多信息,请参见此处

于 2016-02-15T16:09:59.337 回答