PrintSystemDesiredAccess 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定不同的存取權限 (或存取層級) 給列印物件。
public enum class PrintSystemDesiredAccess
public enum PrintSystemDesiredAccess
type PrintSystemDesiredAccess =
Public Enum 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 構函式。