Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell winspool.drv不工作的openprinter_Powershell_Printing - Fatal编程技术网

Powershell winspool.drv不工作的openprinter

Powershell winspool.drv不工作的openprinter,powershell,printing,Powershell,Printing,作为我项目的一部分,我正在学习如何使用我新加入的“winspool.drv”和“PRINTUI.DLL,printuitery”处理打印机。我正在为此项目使用powershell。问题是,当我尝试使用openprinter方法获取打印机句柄时,我的代码抛出了一个错误 错误:方法调用失败,因为[OpenPrinter1.Program1]不包含名为“OpenPrinterHandle”的方法 代码: : 表示调用。类型定义中的OpenPrinterHandle()方法是一个 要更改行为,只需在方法

作为我项目的一部分,我正在学习如何使用我新加入的“winspool.drv”和“PRINTUI.DLL,printuitery”处理打印机。我正在为此项目使用powershell。问题是,当我尝试使用openprinter方法获取打印机句柄时,我的代码抛出了一个错误 错误:方法调用失败,因为[OpenPrinter1.Program1]不包含名为“OpenPrinterHandle”的方法

代码:

:

表示调用。类型定义中的
OpenPrinterHandle()
方法是一个

要更改行为,只需在方法签名中引入关键字:

public static IntPtr OpenPrinterHandle(string printerName)
然后你应该能够做到:

[OpenPrinter1.Program1]::OpenPrinterHandle($printername)

@马西亚斯:太好了!!!!!!!作为答案张贴,而不是很乐意帮助。在TechNet上的powershell文档中添加了指向“调用静态方法”的链接
public static IntPtr OpenPrinterHandle(string printerName)
[OpenPrinter1.Program1]::OpenPrinterHandle($printername)