|
11 | 11 | #include "Settings.h" |
12 | 12 | #include "SettingsUI.h" |
13 | 13 | #include "SettingsUIHelper.h" |
| 14 | +#include "FileHelper.h" |
14 | 15 | #include "Translations.h" |
15 | 16 | #include "LogManager.h" |
16 | 17 | #include "FNVHash.h" |
@@ -2782,12 +2783,19 @@ void CMenuContainer::ActivateItem( int index, TActivateType type, const POINT *p |
2782 | 2783 | info.lpVerb=MAKEINTRESOURCEA(res-verbOffset); |
2783 | 2784 | info.lpVerbW=MAKEINTRESOURCEW(res-verbOffset); |
2784 | 2785 | info.nShow=SW_SHOWNORMAL; |
| 2786 | + bool bOpenTruePath=false; |
| 2787 | + wchar_t targetlnkPath[_MAX_PATH]; // path to target.lnk in a fake folder |
2785 | 2788 | wchar_t dir[_MAX_PATH]; |
2786 | 2789 | if (SHGetPathFromIDList(pItemPidl1,dir)) |
2787 | 2790 | { |
2788 | | - PathRemoveFileSpec(dir); |
2789 | | - if (GetFileAttributes(dir)!=INVALID_FILE_ATTRIBUTES) |
2790 | | - info.lpDirectoryW=dir; |
| 2791 | + if (_stricmp(command,"open")==0 && GetSettingBool(L"OpenTruePath") && GetFakeFolder(targetlnkPath,_countof(targetlnkPath),dir)) |
| 2792 | + bOpenTruePath=true; |
| 2793 | + else |
| 2794 | + { |
| 2795 | + PathRemoveFileSpec(dir); |
| 2796 | + if (GetFileAttributes(dir)!=INVALID_FILE_ATTRIBUTES) |
| 2797 | + info.lpDirectoryW=dir; |
| 2798 | + } |
2791 | 2799 | } |
2792 | 2800 | if (pPt) |
2793 | 2801 | { |
@@ -2818,9 +2826,20 @@ void CMenuContainer::ActivateItem( int index, TActivateType type, const POINT *p |
2818 | 2826 | ::SetForegroundWindow(g_OwnerWindow); |
2819 | 2827 | ::SetWindowPos(g_OwnerWindow,HWND_TOPMOST,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,0); |
2820 | 2828 | LOG_MENU(LOG_EXECUTE,L"Invoke command, ptr=%p, command='%S'",this,command); |
2821 | | - HRESULT hr=pInvokeMenu->InvokeCommand((LPCMINVOKECOMMANDINFO)&info); |
2822 | | - LOG_MENU(LOG_EXECUTE,L"Invoke command, ptr=%p, res=%d",this,hr); |
2823 | | - if (type==ACTIVATE_EXECUTE && SUCCEEDED(hr)) |
| 2829 | + bool executeSuccess; |
| 2830 | + if (bOpenTruePath) // we are trying to open a fake folder, directly open target.lnk instead |
| 2831 | + { |
| 2832 | + HINSTANCE hinst=ShellExecute(NULL,NULL,targetlnkPath,NULL,NULL,SW_SHOWNORMAL); |
| 2833 | + LOG_MENU(LOG_EXECUTE,L"Invoke command, ptr=%p, res=%d",this,hinst); |
| 2834 | + executeSuccess=static_cast<int>(reinterpret_cast<uintptr_t>(hinst))>=32; |
| 2835 | + } |
| 2836 | + else |
| 2837 | + { |
| 2838 | + HRESULT hr=pInvokeMenu->InvokeCommand((LPCMINVOKECOMMANDINFO)&info); |
| 2839 | + LOG_MENU(LOG_EXECUTE,L"Invoke command, ptr=%p, res=%d",this,hr); |
| 2840 | + executeSuccess=SUCCEEDED(hr); |
| 2841 | + } |
| 2842 | + if (type==ACTIVATE_EXECUTE && executeSuccess) |
2824 | 2843 | { |
2825 | 2844 | if (bTrackRecent) |
2826 | 2845 | { |
|
0 commit comments