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”。