|
//
// (C) Copyright by Victor Derks <vba64@xs4all.nl>
//
// See README.TXT for the details of the software licence.
//
#pragma once
#include "../include/cfhandler.h"
#include "../include/cfshellidlist.h"
// Note: owner of the instance of this class must keep passed dataobject alive.
// This class doesn't do addref to prevent circulair referencing.
class CCfFileDescriptorHandler : public CCfHandler
{
public:
CCfFileDescriptorHandler(IDataObject* pdataobjectOuter) :
CCfHandler(CFSTR_FILEDESCRIPTOR, true, false),
m_pdataobject(pdataobjectOuter)
{
}
virtual void GetData(const FORMATETC&, STGMEDIUM& medium) const
{
CCfShellIdList cfshellidlist(m_pdataobject);
size_t size = sizeof(FILEGROUPDESCRIPTOR) +
(cfshellidlist.GetItemCount() * sizeof(FILEDESCRIPTOR));
HGLOBAL hg = GlobalAllocThrow(size);
FILEGROUPDESCRIPTOR* pfgd = static_cast<FILEGROUPDESCRIPTOR*>(hg);
pfgd->cItems = static_cast<UINT>(cfshellidlist.GetItemCount());
for (unsigned int i = 0; i < pfgd->cItems; ++i)
{
FILEDESCRIPTOR& fd = pfgd->fgd[i];
fd.dwFlags = FD_FILESIZE;
fd.nFileSizeHigh = 0;
CVVVItem vvvitem(cfshellidlist.GetItem(i)->mkid);
fd.nFileSizeLow = min(vvvitem.GetSize(), MAX_VVV_ITEM_SIZE);
lstrcpyn(fd.cFileName, vvvitem.GetDisplayName(), MAX_PATH);
}
CStgMedium::SetHGlobal(medium, hg);
}
private:
CCfFileDescriptorHandler& operator=(const CCfFileDescriptorHandler&); // not implemented.
IDataObject* m_pdataobject;
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Victor lives in Nijmegen, the oldest city in The Netherlands.
He studied Applied Physics in Delft and works Hitachi High-Tech Analytical Science.