c++ - Windows Shell Extension doesn't give exact file paths -
I am currently writing a shell extension because the file does not correspond to my needs in a regular way to expand the context menu , Though I have to face the same problem here.
If I right-click on the right shortcut (* .lnk file), then I get a way to its target, if I select multiple files and right-click on the shortcut then only me Finds a file - shortcuts target file.
My shell extension is not yet finished, but the part of the code that counts the files is:
HRESULT CFileContextMenuExt :: Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject * pdtobj, HKEY hkeyProgID) {HRESULT hr = E_INVALIDARG; If (navel == pdtobj) {return hr; } FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; STGMEDIUM STM = {}; // pDataObj has been worked on objects in this example, // we get an HDROP handle to enumerate the selected files. If (SUCCEEDED (pdtobj- & gt; GetData (& amp; FAC & amp; amp; STM)) // Get an HDROP handle HDROPHDRP = Static_Cast & lt; HDORP & gt; (Global Lock (STMHGLOBL)); If (hDrop! = NULL) {// Determine how many files are included in this operation, UINT NFFile = Dragackage file (HDROP, 0xFFFFFFFF, Zero, 0); If (nFiles! = 0) {m_selectedFiles.clear (); // For the selected files and directories (for UINT i = 0; i & lt; nFiles; i ++) {// Get the next file name, Int size = Dragackage file (HD, I, Null, 0) + 1 ; String_t str; Str.resize (size); If (dragquitefile (hradrop, i, and straw [0], size) == 0 continue; M_selectedFiles.push_back (STR); } Hour = S_OK; } Global Yolk (stm.hGlobal); } Release TrustMedium (& amp; nbsp; STM); } // If the value other than S_OK has been returned from the method, the context // menu is not displayed. Returns HR; }
Does anyone recommend how to get the exact path rather than the goal?
(I'm not sure the following solution is perfect and maybe in some cases it works correctly But in the standard case I have tested this fine)
You have to register the context menu handler * and * lnkfile means that when users click on the shortcut, then give the querycontact menu The first time the shortcut file will be called for the target Second time for tar and shortcut file. But there is a slight difference Shortcut file is always close to CMF_VERBSONLY for the target shell and this flag is absent for the shortcut file. So just check this flag and add if anything exists.
Comments
Post a Comment