Restore file drag and drop

Viewed 293

I want to block file drag and drop on an application. For this, I can use win32 API

[DllImport("ole32.dll")]
public static extern int RevokeDragDrop(UIntPtr hwnd);

Now, I would like to restore the drag and drop for that application. Is there any API to restore it back?

1 Answers

You'd use the RegisterDragDrop function, which is how it was (likely) originally set.

From https://docs.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-registerdragdrop:

If your application can accept dropped objects during OLE drag-and-drop operations, you must call the RegisterDragDrop function. Do this whenever one of your application windows is available as a potential drop target, i.e., when the window appears unobscured on the screen.

Related