Willy-Kimura / SharpClipboard

A library for anonymously monitoring clipboard entries.
188 stars 36 forks source link

Clipboard.GetDataObject need singleton #20

Open BBUBBA opened 3 years ago

BBUBBA commented 3 years ago

image

If Hook WM_DRAWCLIPBOARD Multiple Process

Hook event is good work Data is Empty. -_- ( It's Sometime ) ( WM_CLIPBOARDUPDATE is Same Trouble ) ( I tried Global Mutex Control Critical Section = Same Trouble) ( I Think Just One Process and need IPC Communication )

It's OS Stupid But we need Solve that...

and we need use WM_CLIPBOARDUPDATE if over Windows Vista....

if WM_DRAWCLIPBOARD Die about Chain Clipboard is Stupid ( About Another Process )

it's My dirty Code.... ( Warning : My english is not good...)

class ClipboardManager : ClipboardCommon, IClipboardManager
{

    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
    protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case NativeConstant.WM_CLIPBOARDUPDATE:
                ClipboardChange_Proc();
                //Trace.WriteLine("ChangeClipboard");
                break;
        }
        base.WndProc(ref m);
    }

    public ClipboardManager()
    {
        RegisterClipboardViewer();
    }

    public override void RegisterClipboardViewer()
    {
        Native.AddClipboardFormatListener(this.Handle);
    }

    public override void UnregisterClipboardViewer()
    {
        try
        {
            Native.RemoveClipboardFormatListener(this.Handle);
        }
        catch (ObjectDisposedException ex) { }
    }

}
Willy-Kimura commented 3 years ago

Great, thanks for the update!