Clipboard 類別

定義

提供利於將資料傳入和傳出系統剪貼簿的靜態方法。Provides static methods that facilitate transferring data to and from the system Clipboard.

public ref class Clipboard abstract sealed
public static class Clipboard
type Clipboard = class
Public Class Clipboard
繼承
Clipboard

範例

下列範例顯示如何將資料新增至系統剪貼簿。The following example shows how to add data to the system Clipboard.


// For this example, the data to be placed on the clipboard is a simple
// string.
string textData = "I want to put this string on the clipboard.";

// After this call, the data (string) is placed on the clipboard and tagged
// with a data format of "Text".
Clipboard.SetData(DataFormats.Text, (Object)textData);
' For this example, the data to be placed on the clipboard is a simple
' string.
Dim textData As String = "I want to put this string on the clipboard."

' After this call, the data (string) is placed on the clipboard and tagged
' with a data format of "Text".
Clipboard.SetData(DataFormats.Text, CType(textData, Object))

備註

所有的WindowsWindows應用程式都會共用系統剪貼簿, 因此當您切換到另一個應用程式時, 內容可能會變更。All applications for WindowsWindows share the system Clipboard, so the contents are subject to change when you switch to another application.

如需可與Clipboard類別搭配使用的預先定義格式清單, DataFormats請參閱類別。For a list of predefined formats available to use with the Clipboard class, see the DataFormats class.

安全性警示: 基於安全考慮, 應記住下列幾點。Security Alert: For security purposes, the following points should be kept in mind.

  • 貼上作業必須是 [使用者起始] (Ctrl + V、[貼上] 功能表)。Paste operations need to be user initiated (Ctrl-V, Paste Menu).

  • 複製只能在使用者選取的內容上。Copy can only be on user selected content.

  • 在複製或剪下時, 部分信任程式碼Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)會將純文字和放在剪貼簿上。On copy or cut, partial trust code puts plaintext and Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) on to the clipboard. 純文字包括文字、Unicode 文字、OEM (物件交換模型) 文字和 CSV (逗點分隔值)。Plaintext includes text, Unicode text, OEM (Object Exchange Model) text, and CSV (Comma-separated values).

  • 貼上時Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) , Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)如果該內容的來源來自相同信任或更受信任的網站, 則會貼上。On paste, Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) will paste in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) if the source of that content is from a equally trusted or more trusted site. 尤其是:Specifically:

    • 部分信任的應用程式可以Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)從完全信任的應用程式貼上。A partial trust application can paste Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) from a full trust application.

    • 部分信任的應用程式可以Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)從部分信任的應用程式貼上。A partial trust application can paste Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) from a partial trust application.

    • 完全信任的應用程式只能從另一個完全受信任的應用程式貼上 XAML。A full trust application can paste XAML only from another fully trusted application.

    • Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)完全信任的應用程式可以在剪貼簿上檢查 ApplicationTrust 格式, 並在適當時淨化 XAML。A non-Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) full trust application can examine the ApplicationTrust format on the clipboard and sanitize the XAML if appropriate.

方法

Clear()

清除系統剪貼簿上的任何資料。Clears any data from the system Clipboard.

ContainsAudio()

查詢 [剪貼簿] 中是否有 WaveAudio 資料格式的資料。Queries the Clipboard for the presence of data in the WaveAudio data format.

ContainsData(String)

查詢剪貼簿上是否有指定之資料格式的資料存在。Queries the Clipboard for the presence of data in a specified data format.

ContainsFileDropList()

查詢 [剪貼簿] 中是否有 FileDrop 資料格式的資料。Queries the Clipboard for the presence of data in the FileDrop data format.

ContainsImage()

查詢 [剪貼簿] 中是否有 Bitmap 資料格式的資料。Queries the Clipboard for the presence of data in the Bitmap data format.

ContainsText()

查詢剪貼簿中是否有 UnicodeText 格式的資料。Queries the Clipboard for the presence of data in the UnicodeText format.

ContainsText(TextDataFormat)

查詢剪貼簿中是否有文字資料格式的資料。Queries the Clipboard for the presence of data in a text data format.

Flush()

永久新增 Clipboard 上的資料,使資料在原始應用程式關閉之後可供使用。Permanently adds the data that is on the Clipboard so that it is available after the data's original application closes.

GetAudioStream()

傳回 WaveAudio 資料格式之剪貼簿資料的資料流。Returns a stream of Clipboard data in the WaveAudio data format.

GetData(String)

從剪貼簿擷取指定之格式的資料。Retrieves data in a specified format from the Clipboard.

GetDataObject()

傳回資料物件,這個物件代表剪貼簿的整個內容。Returns a data object that represents the entire contents of the Clipboard.

GetFileDropList()

傳回字串集合,其中包含剪貼簿上已置放檔案的清單。Returns a string collection that contains a list of dropped files available on the Clipboard.

GetImage()

從剪貼簿傳回 BitmapSource 物件,其中包含 Bitmap 格式的資料。Returns a BitmapSource object from the Clipboard that contains data in the Bitmap format.

GetText()

傳回字串,其中包含剪貼簿上的 UnicodeText 資料。Returns a string containing the UnicodeText data on the Clipboard.

GetText(TextDataFormat)

傳回字串,其中包含剪貼簿上的文字資料。Returns a string containing text data on the Clipboard.

IsCurrent(IDataObject)

比較指定的資料物件與剪貼簿的內容。Compares a specified data object to the contents of the Clipboard.

SetAudio(Byte[])

在 [剪貼簿] 上儲存音訊資料 (WaveAudio 資料格式)。Stores audio data (WaveAudio data format) on the Clipboard. 音訊資料會指定為位元組陣列。The audio data is specified as a byte array.

SetAudio(Stream)

在 [剪貼簿] 上儲存音訊資料 (WaveAudio 資料格式)。Stores audio data (WaveAudio data format) on the Clipboard. 音訊資料可指定為資料流。The audio data is specified as a stream.

SetData(String, Object)

以指定的格式將指定的資料儲存在剪貼簿上。Stores the specified data on the Clipboard in the specified format.

SetDataObject(Object)

將指定的非持續性資料物件放在系統剪貼簿上。Places a specified non-persistent data object on the system Clipboard.

SetDataObject(Object, Boolean)

將指定的資料物件放在系統剪貼簿上,並接受布林參數以指出在應用程式結束時是否應保留剪貼簿上的資料物件。Places a specified data object on the system Clipboard and accepts a Boolean parameter that indicates whether the data object should be left on the Clipboard when the application exits.

SetFileDropList(StringCollection)

在 [剪貼簿] 上儲存 FileDrop 資料。Stores FileDrop data on the Clipboard. 已置放的檔案清單會指定為字串集合。The dropped file list is specified as a string collection.

SetImage(BitmapSource)

在 [剪貼簿] 上儲存 Bitmap 資料。Stores Bitmap data on the Clipboard. 影像資料會指定為 BitmapSourceThe image data is specified as a BitmapSource.

SetText(String)

在 [剪貼簿] 上儲存 UnicodeText 資料。Stores UnicodeText data on the Clipboard.

SetText(String, TextDataFormat)

以指定的文字資料格式將文字資料儲存在剪貼簿上。Stores text data on the Clipboard in a specified text data format. 要儲存的 UnicodeText 資料會指定為字串。The UnicodeText data to store is specified as a string.

適用於

另請參閱