ClipboardProxy Class

Provides methods for manipulating the Clipboard.

System.Object
  Microsoft.VisualBasic.MyServices.ClipboardProxy

Namespace:  Microsoft.VisualBasic.MyServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
public class ClipboardProxy

The ClipboardProxy type exposes the following members.

  NameDescription
Public methodClearClears the Clipboard.
Public methodContainsAudioIndicates whether the Clipboard contains audio data.
Public methodContainsDataIndicates whether the Clipboard contains data in the specified custom format.
Public methodContainsFileDropListReturns a Boolean indicating whether the Clipboard contains a file drop list.
Public methodContainsImageReturns a Boolean indicating whether an image is stored on the Clipboard.
Public methodContainsText()Determines if there is text on the Clipboard.
Public methodContainsText(TextDataFormat)Determines if there is text on the Clipboard.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAudioStreamRetrieves an audio stream from the Clipboard.
Public methodGetDataRetrieves data in a custom format from the Clipboard.
Public methodGetDataObjectRetrieves data from the Clipboard as an IDataObject.
Public methodGetFileDropListRetrieves a collection of strings representing file names from the Clipboard.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetImageRetrieves an image from the Clipboard.
Public methodGetText()Retrieves text from the Clipboard.
Public methodGetText(TextDataFormat)Retrieves text from the Clipboard.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetAudio(Byte[])Writes audio data to the Clipboard.
Public methodSetAudio(Stream)Writes audio data to the Clipboard.
Public methodSetDataWrites data in a custom format to the Clipboard.
Public methodSetDataObjectWrites a DataObject to the Clipboard.
Public methodSetFileDropListWrites a collection of strings representing file paths to the Clipboard.
Public methodSetImageWrites an image to the Clipboard.
Public methodSetText(String)Writes text to the Clipboard.
Public methodSetText(String, TextDataFormat)Writes text to the Clipboard.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Items moved or copied to the Clipboard persist even after the application is shut down.

Data on the Clipboard can be in any data format, also called a Clipboard format. For a list of predefined formats to use with the Clipboard, see DataFormats. When an item is moved or copied to the Clipboard, items in other formats are cleared. To make other formats persist, use DataObject, which copies everything existing on the current Clipboard, including items pasted from other applications. Place data on the Clipboard in multiple formats to maximize the possibility that a target application, whose format requirements you might not know, can successfully retrieve the data.

Because all Windows applications share the system Clipboard, the contents may change when you switch to another application.

A class must be serializable for it to be put on the Clipboard. See Serialization (C# and Visual Basic) for more information.

When accessing the Clipboard remotely, a ThreadStateException is thrown unless the accessing thread operates in STA (single-threaded apartment) mode. To resolve this issue, set the ThreadApartmentState to STA. For more information, see STAThreadAttribute.

For more information, see Storing Data to and Reading from the Clipboard (Visual Basic).

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Resources. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

This example reads text from the Clipboard into the string textOnClipboard.

Dim textOnClipboard As String = My.Computer.Clipboard.GetText()

This example will fail if there is no text on the Clipboard.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft