PrintBooleanProperty 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 PrintBooleanProperty 類別的新執行個體。
多載
PrintBooleanProperty(String) |
初始化 PrintBooleanProperty 類別的新執行個體,使其具有指定屬性。 |
PrintBooleanProperty(String, Object) |
初始化 PrintBooleanProperty 類別的新執行個體,使其具有正在使用指定值的指定屬性。 |
PrintBooleanProperty(String)
初始化 PrintBooleanProperty 類別的新執行個體,使其具有指定屬性。
public:
PrintBooleanProperty(System::String ^ attributeName);
public PrintBooleanProperty (string attributeName);
new System.Printing.IndexedProperties.PrintBooleanProperty : string -> System.Printing.IndexedProperties.PrintBooleanProperty
Public Sub New (attributeName As String)
參數
- attributeName
- String
Boolean 所表示 PrintBooleanProperty 屬性的名稱。
備註
attributeName
應該拼字與列印系統物件之某些特定Boolean屬性的名稱完全相同,包括大小寫。 例如, IsBusy 對象的 屬性 PrintQueue 必須拼字為 “IsBusy”,而不是 “Busy” 或 “Isbusy”。
適用於
PrintBooleanProperty(String, Object)
初始化 PrintBooleanProperty 類別的新執行個體,使其具有正在使用指定值的指定屬性。
public:
PrintBooleanProperty(System::String ^ attributeName, System::Object ^ attributeValue);
public PrintBooleanProperty (string attributeName, object attributeValue);
new System.Printing.IndexedProperties.PrintBooleanProperty : string * obj -> System.Printing.IndexedProperties.PrintBooleanProperty
Public Sub New (attributeName As String, attributeValue As Object)
參數
- attributeName
- String
Boolean 表示之 PrintBooleanProperty 屬性的名稱。
- attributeValue
- Object
PrintBooleanProperty 所表示屬性的值。
範例
下列範例示範如何在安裝第二部印表機時使用此建構函式,而該印表機的屬性與現有印表機不同的位置、埠和共享狀態。
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()
備註
attributeName
應該拼字與列印系統物件之某些特定Boolean屬性的名稱完全相同,包括大小寫。 例如, IsBusy 對象的 屬性 PrintQueue 必須拼字為 “IsBusy”,而不是 “Busy” 或 “Isbusy”。