Search code examples
c++winapidrag-and-dropolefile-type

File-Drop mechanism of some associated filetypes (.zip, .rar,...)


I would like to know , how file manager like WinRAR manage it to enable Drag & Drop support for their archive file (when a file is dropped on a .rar-file it opens and optionally WinRAR adds the file to archive).

Image for demonstration: enter image description here

EDIT: After some comment, I want to clarify what I want to do (see Image):

  1. Files of a certain data type accept a Drop request (.rar).
  2. Dropping the file (.txt) result in a Shell-call that passes the name of the dropped file (.txt) as well as the name of the file which accepted the Drop (.rar).
  3. The application registered to the file type is called, both filenames are provided to it in the command line.

Solution

  • You need to implement a Shell Drop Handler.

    This is a COM object which implements the IPersistFile and IDropTarget interfaces. IPersistFile will tell you which file is being dropped on. IDropTarget will give you an IDataObject to tell you which files/data are being dropped.

    The documentation is here: