Drag/Drop from Filesystem
by S2FsbGlNYW4 » Thu, 02 Jun 2005 04:04:02 GMT
try with this:
STDMETHODIMP CContextMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT
lpdobj, HKEY hkeyProgID)
{
DWORD dwErrcode = 0L;
FORMATETC fe;
STGMEDIUM stgmed;
fe.cfFormat = CF_HDROP;
fe.ptd = NULL;
fe.dwAspect = DVASPECT_CONTENT;
fe.lindex = -1;
fe.tymed = TYMED_HGLOBAL;
// Get the storage medium from the data object.
HRESULT hr = lpdobj->GetData(&fe, &stgmed);
m_arrFileNames.RemoveAll();
if (SUCCEEDED(hr))
{
if(stgmed.hGlobal)
{
int iSize = 0;
LPDROPFILES pDropFiles = (LPDROPFILES)GlobalLock(stgmed.hGlobal);
LPTSTR pszFiles = NULL, pszTemp = NULL;
LPWSTR pswFiles = NULL, pswTemp = NULL;
if (pDropFiles->fWide)
{
pswFiles = (LPWSTR) ((BYTE*) pDropFiles + pDropFiles->pFiles);
pswTemp = (LPWSTR) ((BYTE*) pDropFiles + pDropFiles->pFiles);
m_arrFileNames.Add(_bstr_t(pswFiles));
}
else
{
pszFiles = (LPTSTR) pDropFiles + pDropFiles->pFiles;
pszTemp = (LPTSTR) pDropFiles + pDropFiles->pFiles;
m_arrFileNames.Add(pszFiles);
}
}
GlobalUnlock(stgmed.hGlobal);
ReleaseStgMedium(&stgmed);
}
else
dwErrcode = GetLastError();
return NOERROR;
}