PrintSystemDesiredAccess 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定列印物件的不同訪問許可權(或存取層級)。
public enum class PrintSystemDesiredAccess
public enum PrintSystemDesiredAccess
type PrintSystemDesiredAccess =
Public Enum PrintSystemDesiredAccess
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| None | 0 | 無存取權限。 |
| EnumerateServer | 131074 | 有權在列印伺服器上列出佇列。 |
| UsePrinter | 131080 | 有權將列印工作加入隊列,並刪除及列舉自己的工作。 |
| AdministrateServer | 983041 | 有權執行列印伺服器的所有管理任務。 此存取層 級不 包含 AdministratePrinter 伺服器所託管列印佇列的權限。 |
| AdministratePrinter | 983052 | 執行列印佇列所有行政任務的權利,包括暫停與恢復任何列印任務的權利;以及刪除所有佇列中工作任務的權利。 此存取層級也包含所有權利。UsePrinter |
範例
以下範例說明如何利用此枚舉安裝第二台印表機,其特性僅在位置、埠及共享狀態上與現有印表機不同。
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()
備註
各級存取權限依以下條件而異:
無論列印伺服器是電腦還是列印伺服器設備。
所使用的作業系統。
安裝的安全更新。
所支援的安全政策。
因此,「成員」區塊中的存取權描述通常是對應各存取層級的權利,但列出的存取等級可能對特定系統提供更多或更少的權限。
這些值主要用作 和 PrintServer 的參數PrintQueue。 如果你使用只能套用到其他物件的值,建構子會拋出例外。 例如,不要將 AdministratePrinter 傳給 PrintServer 建構者。