Html 形式を書きたいのですが、単純な MSDN の例でさえ動作しません。
http://msdn.microsoft.com/en-us/library/tbfb3z56.aspx
クリップボード ラウンド トリッパーであるこのコンソール アプリは、誰にとっても機能しますか?
システムを使用する;
System.Windows を使用します。//PresentationCore または System.Windows.Forms 参照を追加する必要があります
クラス プログラム {
[スタスレッド]
static void Main( string[] args ) {
Console.WriteLine( "ブラウザーから少量のテキストをコピーし、Enter キーを押します。" );
Console.ReadLine();
var text = Clipboard.GetText();
Console.WriteLine();
Console.WriteLine( "--->テキストとしてのクリップボード:" );
Console.WriteLine( テキスト );
Console.WriteLine();
Console.WriteLine( "--->同じ CF_HTML データでクリップボードを書き換えます。" );
//***これが問題のコードです***
var html = Clipboard.GetText( TextDataFormat.Html );
クリップボード.クリア();
Clipboard.SetText( html, TextDataFormat.Html );
var text2 = Clipboard.GetText();
Console.WriteLine();
Console.WriteLine( "--->テキストとしてのクリップボード:" );
Console.WriteLine( text2 );
var isSameText = (テキスト == テキスト 2 );
Console.WriteLine();
Console.WriteLine( isSameText ? "成功" : "失敗" );
Console.WriteLine();
Console.WriteLine( "Enter キーを押して終了します。" );
Console.ReadLine();
}
}