by DropMaster » Tue Aug 04, 2015 6:42 am
Best approach is to read the code in DMComps.pas and you'll see how it's done by the components themselves.
A couple of other pointers, though.
a) Drag onto the demo app FormatViewer so you can see what formats are actually present. You'll see the formats, the media types and the indices (see below). Then you'll know what to look for when you're writing your code.
b) Sometimes the formats are present not on a global handle but on an IStream or an IStorage. By default, it's assumed that the media type is a TYMED_HGLOBAL (a global handle). To grab a format from e.g. an IStream, you first set the global variable DataObjectTymed := TYMED_ISTREAM and then make your call to DataObjectHasFormat or DataObjectGetFormat; after each such call, DataObjectTymed is reset to TYMED_ISTREAM automatically. For an indexed format, like a list of files, there is DataObjectlIndex which you can set to the (zero-based) element of the format you want to receive. This is all Windows-level stuff and is normally hidden away from you by DM. There are examples of all of this kind of manipulation in the demo applications.
c) Based on the above you may need to supply a different TYMED. Also, it's possible you need to look for FileGroupDescriptorW but that will be clear from step a). If you make the normal call to DataObjectGetFormat and you get nothing back, it means that format is not present on a global handle, or if it's an indexed format, there's nothing at index zero.
d) When you have your format data returned (on an AnsiString) there are helper methods in DMUtil you can use to extract the data, like FileListFromFileGroupDescripor (which returns the list of files from a FileGroupDescriptor into a TStringList), etc. Again there are examples of this kind of usage in the demo applications.
_________________________
DropMaster Support