-4

私は閲覧してきましたが、単に Ctrl+x または Ctrl+c コマンドを送信して data(strings) をコピー/カットする方法は不明ですが、これが必要な pInvoke であると確信しています。クイックハンド、誰か?

[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

おそらくこれと一緒に: [DllImport("user32.dll")] static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);

これらのいずれかを正しく使用する方法がわからない場合は、助けてください。

IntPtr nextClipboardAppWindow;
public frmMain()
{
        nextClipboardAppWindow = (IntPtr)SetClipboardViewer((int)this.Handle);
}

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
        // defined in winuser.h
        const int WM_DRAWCLIPBOARD = 0x308;
        const int WM_CHANGECBCHAIN = 0x030D;
        switch (m.Msg)
        {
            case WM_DRAWCLIPBOARD:
                //DisplayClipboardData();
                SendMessage(nextClipboardAppWindow, m.Msg, m.WParam,
                            m.LParam);
                break;

            case WM_CHANGECBCHAIN:
                if (m.WParam == nextClipboardAppWindow)
                    nextClipboardAppWindow = m.LParam;
                else
                    SendMessage(nextClipboardAppWindow, m.Msg, m.WParam,
                                m.LParam);
                break;

            default:
                base.WndProc(ref m);
                break;
        }
    }
4

1 に答える 1

-1

.Net を使用していてアクセスできる場合は、クラスをSystem.Windows.Forms使用してデータをクリップボードに保存できます。例を含むMSDNへのリンクを次に示します。ClipboardSetGet

http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx

Clipboardクラスは実際にデータをシステム クリップボードにポストします。アプリケーションに拘束されるものではありません。次のように簡単です

System.Windows.Forms.Clipboard.SetText("This will be available across all applications");

于 2013-02-09T06:24:15.020 に答える