如何在asp.net中连接远程打印机 [英] how to connect remote printer in asp.net
问题描述
PrintServer myPrintServer =新的PrintServer(@"\\ DINAZ-PC \ doPDF v7",PrintSystemDesiredAccess.EnumerateServer);
PrintServer myPrintServer = new PrintServer(@"\\DINAZ-PC\doPDF v7", PrintSystemDesiredAccess.EnumerateServer);
这是我的代码,因为出现错误,所以在创建PrintServer对象时发生了异常. Win32错误:访问被拒绝.
this is my code and i got error as An exception occurred while creating the PrintServer object. Win32 error: Access is denied.
请向我展示一些使用PrintServer方法访问打印机的示例代码.
Pls show me some sample code for accessing printer using PrintServer method.
推荐答案
1-第一个选项是手动添加打印机到本地打印机,然后访问它.
1- First option is to add the Printer manually to your local printers, then access it.
2-您可以使用此代码连接到网络打印机.
2- you can use this code to connect to network printer.
[DllImport("winspool.drv")]
public static extern bool AddPrinterConnection(string PrinterName);
[DllImport("winspool.drv")]
public static extern bool SetDefaultPrinter(string printerName);
private void ConnectToNetworkPrinter()
{
bool result = AddPrinterConnection(@"\\ServerName\PrinterName");
bool resultdef = SetDefaultPrinter(@"\\ServerName\PrinterName");
}
这篇关于如何在asp.net中连接远程打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!