At the moment I'm writing a Shell extension, because regular way to extend file context menu doesn't fit my needs, however I face the same problem here.
If I right click single shortcut (*.lnk file) I get its target path, if I select many files and right click on shortcut I only get one file - shortcuts target file.
My shell extension is not finished yet, but part of code which enumerates files is this:
HRESULT CFileContextMenuExt::Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
{
HRESULT hr = E_INVALIDARG;
if (NULL == pdtobj)
{
return hr;
}
FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM stm = {};
// pDataObj contains the objects being acted upon. In this example,
// we get an HDROP handle for enumerating the selected files.
if (SUCCEEDED(pdtobj->GetData(&fe, &stm)))
{
// Get an HDROP handle.
HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));
if (hDrop != NULL)
{
// Determine how many files are involved in this operation.
UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
if (nFiles != 0)
{
m_selectedFiles.clear();
//Enumerates the selected files and directories.
for (UINT i = 0; i < nFiles; i++)
{
// Get the next filename.
int size = DragQueryFile(hDrop, i, NULL, 0) + 1;
string_t str;
str.resize(size);
if (DragQueryFile(hDrop, i, &str[0], size) == 0)
continue;
m_selectedFiles.push_back(str);
}
hr = S_OK;
}
GlobalUnlock(stm.hGlobal);
}
ReleaseStgMedium(&stm);
}
// If any value other than S_OK is returned from the method, the context
// menu is not displayed.
return hr;
}
Can someone advice how to get exact paths instead of targets?