Share via


方法 : クリップボード内にテキストを格納する

更新 : 2007 年 11 月

System.Windows.Forms 名前空間で定義される Clipboard オブジェクトを使用して、文字列を格納する方法を次のコード例に示します。このオブジェクトには、SetDataObjectGetDataObject の 2 つのメンバ関数が用意されています。Object から派生した任意のオブジェクトを SetDataObject に送信することで、クリップボードにデータが格納されます。

使用例

// store_clipboard.cpp
// compile with: /clr
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Windows::Forms;

[STAThread] int main()
{
   String^ str = "This text is copied into the Clipboard.";

   // Use 'true' as the second argument if
   // the data is to remain in the clipboard
   // after the program terminates.
   Clipboard::SetDataObject(str, true);

   Console::WriteLine("Added text to the Clipboard.");

   return 0;
}

参照

処理手順

方法 : クリップボードからテキストを取得する

その他の技術情報

C++ における Windows の操作

.NET プログラミング ガイド