PrintStringProperty 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 PrintStringProperty 类的新实例。
重载
PrintStringProperty(String) |
针对指定的属性初始化 PrintStringProperty 类的新实例。 |
PrintStringProperty(String, Object) |
初始化 PrintStringProperty 类的新实例,该类具有指定属性的指定值。 |
PrintStringProperty(String)
针对指定的属性初始化 PrintStringProperty 类的新实例。
public:
PrintStringProperty(System::String ^ attributeName);
public PrintStringProperty (string attributeName);
new System.Printing.IndexedProperties.PrintStringProperty : string -> System.Printing.IndexedProperties.PrintStringProperty
Public Sub New (attributeName As String)
参数
- attributeName
- String
String 表示的 PrintStringProperty 属性的名称。
注解
attributeName
的拼写应与打印系统对象的某些特定String属性的名称(包括大小写)完全相同。 例如, Submitter 对象的 属性 PrintSystemJobInfo 必须拼写为“Submitter”,而不是“submitter”。
适用于
PrintStringProperty(String, Object)
初始化 PrintStringProperty 类的新实例,该类具有指定属性的指定值。
public:
PrintStringProperty(System::String ^ attributeName, System::Object ^ attributeValue);
public PrintStringProperty (string attributeName, object attributeValue);
new System.Printing.IndexedProperties.PrintStringProperty : string * obj -> System.Printing.IndexedProperties.PrintStringProperty
Public Sub New (attributeName As String, attributeValue As Object)
参数
- attributeName
- String
String 表示的 PrintStringProperty 属性的名称。
- attributeValue
- Object
PrintStringProperty 表示的属性的值。
示例
以下示例演示如何使用此构造函数安装第二台打印机,该打印机的属性与现有打印机仅在位置、端口和共享状态上不同。
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
的拼写应与打印系统对象的某些特定String属性的名称(包括大小写)完全相同。 例如, Submitter 对象的 属性 PrintSystemJobInfo 必须拼写为“Submitter”,而不是“submitter”。