Enable drag and drop from Explorer to Launch as Administrator

I created a winforms application and implemented the drag & drop function. this functionality works fine in WinXP or in Win7 from Run-As-Administrator applications.

Problems arise when tring drags from a non-admin application into Win7 into my program, it just doesn't work.

I understand this because the OS filters messages. I found a solution for this here: http://blog.helgeklein.com/2010/03/how-to-enable-drag-and-drop-for.html , but it does not work.

here is the workaround:

    [DllImport("user32.dll", SetLastError = true)]
    static extern bool ChangeWindowMessageFilter(uint message, uint dwFlag);

    private const uint WM_DROPFILES = 0x233;
    private const uint WM_COPYDATA = 0x004A;
    private const uint WM_COPYGLOBALDATA = 0x0049;
    private const uint MSGFLT_ADD = 1;

    ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
    ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
    ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);

How to make it work?

+3
source share
1

, UIPI, UAC, . , ChangeWindowMessageFilter() Windows.

OLE Windows. , RegisterDragDrop(). microsoftie , , CWMF. , WM_DROPFILES, . DragAcceptFiles() Windows Forms .

+7

Source: https://habr.com/ru/post/1766552/


All Articles