방법: 클립보드에 텍스트 저장(C++/CLI)
다음 코드 예제에서는 System.Windows.Forms 네임스페이스에 정의된 Clipboard 개체를 사용하여 문자열을 저장합니다. 이 개체는 SetDataObject 및 GetDataObject라는 두 가지 멤버 함수를 제공합니다. 데이터는 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;
}