本文介绍了如何在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.
推荐答案
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中连接远程打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!