PrintStringProperty 类

定义

表示打印系统硬件或软件组件的 String 属性(及其值)。

public ref class PrintStringProperty sealed : System::Printing::IndexedProperties::PrintProperty
[System.Serializable]
public sealed class PrintStringProperty : System.Printing.IndexedProperties.PrintProperty
public sealed class PrintStringProperty : System.Printing.IndexedProperties.PrintProperty
[<System.Serializable>]
type PrintStringProperty = class
    inherit PrintProperty
type PrintStringProperty = class
    inherit PrintProperty
Public NotInheritable Class PrintStringProperty
Inherits PrintProperty
继承
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()

构造函数

PrintStringProperty(String)

针对指定的属性初始化 PrintStringProperty 类的新实例。

PrintStringProperty(String, Object)

初始化 PrintStringProperty 类的新实例,该类具有指定属性的指定值。

属性

IsDisposed

获取或设置一个值,该值指示该对象是否已被释放。

(继承自 PrintProperty)
IsInitialized

获取或设置一个值,该值指示该对象是否已初始化。

(继承自 PrintProperty)
Name

在派生类中重写时,获取该对象表示的属性的名称。

(继承自 PrintProperty)
Value

获取或设置 PrintStringProperty 表示的属性的值。

方法

Dispose()

释放正在由 PrintProperty 使用的所有资源。

(继承自 PrintProperty)
Dispose(Boolean)

释放正在由 PrintProperty 占用的非托管资源,还可以另外再释放托管资源。

(继承自 PrintProperty)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
InternalDispose(Boolean)

释放正在由 PrintProperty 占用的非托管资源,还可以另外再释放托管资源。

(继承自 PrintProperty)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OnDeserialization(Object)

在派生类中重写时,实现 ISerializable 接口,并在完成反序列化之后引发反序列化事件。

(继承自 PrintProperty)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

运算符

Implicit(PrintStringProperty to String)

提供从指向 String 的指针到 PrintStringProperty 值的隐式转换。

适用于