在windwos 2003操作系统下,发布Asp.net 后,下面函数不能获取安装在服务器上共享的打印机列表,可以得到该机器安装的本地打印,请问高手,如可配置权限后,Asp.net 可以操作网络上的共享打印机.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using Maticsoft.DBUtility;
using System.Drawing.Printing;
using System.Web;
using System.Runtime.InteropServices;
public static List<string> GetPrinterList()
{
/// <summary>
/// 获取本机的打印机列表。列表中的第一项就是默认打印机。
List<String> fPrinters = new List<string>();
// fPrinters.Add(DefaultPrinter); // 默认打印机始终出现在列表的第一项
foreach (String fPrinterName in PrinterSettings.InstalledPrinters)
{
if (!fPrinters.Contains(fPrinterName))
fPrinters.Add(fPrinterName);
}
return fPrinters;
}
////设置共享打印机的函数也不灵 [DllImport("Winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool SetDefaultPrinter(string printerName);
SetDefaultPrinter(strPrinterName);//设置默认打印
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using Maticsoft.DBUtility;
using System.Drawing.Printing;
using System.Web;
using System.Runtime.InteropServices;
public static List<string> GetPrinterList()
{
/// <summary>
/// 获取本机的打印机列表。列表中的第一项就是默认打印机。
List<String> fPrinters = new List<string>();
// fPrinters.Add(DefaultPrinter); // 默认打印机始终出现在列表的第一项
foreach (String fPrinterName in PrinterSettings.InstalledPrinters)
{
if (!fPrinters.Contains(fPrinterName))
fPrinters.Add(fPrinterName);
}
return fPrinters;
}
////设置共享打印机的函数也不灵 [DllImport("Winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool SetDefaultPrinter(string printerName);
SetDefaultPrinter(strPrinterName);//设置默认打印
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货