PrintSystemDesiredAccess 枚举

定义

指定打印对象的不同访问权限(或访问级别)。

public enum class PrintSystemDesiredAccess
public enum PrintSystemDesiredAccess
type PrintSystemDesiredAccess = 
Public Enum PrintSystemDesiredAccess
继承
PrintSystemDesiredAccess

字段

AdministratePrinter 983052

执行打印队列的所有管理任务的权限,包括暂停和继续任何打印作业的权限;以及从队列中删除所有作业的权限。 此访问级别还包括 UsePrinter 之下的所有权限。

AdministrateServer 983041

执行打印服务器的所有管理任务的权限。 此访问级别不包括服务器承载的打印队列的 AdministratePrinter 权限

EnumerateServer 131074

列出打印服务器上的队列的权限。

None 0

无访问权限。

UsePrinter 131080

将打印作业添加到队列以及删除和枚举自己的作业的权限。

示例

以下示例演示如何使用此枚举安装第二台打印机,该打印机的属性仅在位置、端口和共享状态上不同于现有打印机。

LocalPrintServer myLocalPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue;
PrintPropertyDictionary myPrintProperties = sourcePrintQueue.PropertiesCollection;

// Share the new printer using Remove/Add methods
PrintBooleanProperty shared = new PrintBooleanProperty("IsShared", true);
myPrintProperties.Remove("IsShared");
myPrintProperties.Add("IsShared", shared);

// Give the new printer its share name using SetProperty method
PrintStringProperty theShareName = new PrintStringProperty("ShareName", "\"Son of " + sourcePrintQueue.Name +"\"");
myPrintProperties.SetProperty("ShareName", theShareName);

// Specify the physical location of the new printer using Remove/Add methods
PrintStringProperty theLocation = new PrintStringProperty("Location", "the supply room");
myPrintProperties.Remove("Location");
myPrintProperties.Add("Location", theLocation);

// Specify the port for the new printer
String[] port = new String[] { "COM1:" };

// Install the new printer on the local print server
PrintQueue clonedPrinter = myLocalPrintServer.InstallPrintQueue("My clone of " + sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties);
myLocalPrintServer.Commit();

// Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName);
Console.WriteLine("Press Return to continue ...");
Console.ReadLine();
Dim myLocalPrintServer As New LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer)
Dim sourcePrintQueue As PrintQueue = myLocalPrintServer.DefaultPrintQueue
Dim myPrintProperties As PrintPropertyDictionary = sourcePrintQueue.PropertiesCollection

' Share the new printer using Remove/Add methods
Dim [shared] As New PrintBooleanProperty("IsShared", True)
myPrintProperties.Remove("IsShared")
myPrintProperties.Add("IsShared", [shared])

' Give the new printer its share name using SetProperty method
Dim theShareName As New PrintStringProperty("ShareName", """Son of " & sourcePrintQueue.Name & """")
myPrintProperties.SetProperty("ShareName", theShareName)

' Specify the physical location of the new printer using Remove/Add methods
Dim theLocation As New PrintStringProperty("Location", "the supply room")
myPrintProperties.Remove("Location")
myPrintProperties.Add("Location", theLocation)

' Specify the port for the new printer
Dim port() As String = { "COM1:" }


' Install the new printer on the local print server
Dim clonedPrinter As PrintQueue = myLocalPrintServer.InstallPrintQueue("My clone of " & sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties)
myLocalPrintServer.Commit()

' Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName)
Console.WriteLine("Press Return to continue ...")
Console.ReadLine()

注解

每个访问权限级别可用的访问权限因以下各项而异:

  • 打印服务器是计算机还是打印服务器设备。

  • 使用的操作系统。

  • 已安装的安全更新。

  • 支持的安全策略。

因此,“成员”部分中的访问权限说明是对应于每个访问级别的典型权限,但列出的访问级别可能在特定系统上提供更多或更少的权限。

这些值主要用作 和 PrintQueue 构造函数的参数PrintServer。 如果使用的值只能应用于另一种对象,则构造函数将引发异常。 例如,不要将 AdministratePrinter 传递给 PrintServer 构造函数。

适用于