0

When I create a common file dialog on Windows, I can add application specific shortcuts on the left pane with IFileDialog::AddPlace.

The shortcuts are all displayed in a virtual folder called "Application Links". But when I click on "Application Links" the folder seems to be empty showing only "No items match your search.": enter image description here

Is it possible to display all the shortcuts listed at "Application Links" on the left pane, also in the right pane when I click on "Application Links" itself? And if so, how can I accomplish that?

Here is a minimal working example of the code producing the screenshot above:

#include <windows.h>
#include <shobjidl.h>

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
    if (SUCCEEDED(hr)) {
        IFileDialog *pfd = NULL;
        hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
        if (SUCCEEDED(hr)) {
            IShellItem *psiShortcut;
            // Get ShellItem for "C:\Windows\System32"
            hr = SHCreateItemFromParsingName(L"C:\\Windows\\System32", 0, IID_IShellItem, (void**) &psiShortcut);
            if (SUCCEEDED(hr)) {
                // Add the ShellItem for "C:\Windows\System32" to the file dialogs shortcut list
                hr = pfd->AddPlace(psiShortcut, FDAP_BOTTOM);
                if (SUCCEEDED(hr)) {
                    // Open file dialog and show result in a message box on OK
                    hr = pfd->Show(NULL);
                    if (SUCCEEDED(hr) && hr != HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
                        IShellItem *psiFileName;
                        hr = pfd->GetResult( &psiFileName);
                        if (SUCCEEDED(hr)) {
                            PWSTR pwszFileName;
                            hr = psiFileName->GetDisplayName(SIGDN_FILESYSPATH, &pwszFileName);
                            if (SUCCEEDED(hr)) {
                                MessageBoxW(NULL, pwszFileName, L"Note", MB_OK);
                                CoTaskMemFree( pwszFileName );
                            }
                            psiFileName->Release();
                        }
                    }
                }
                psiShortcut->Release();
            }
            pfd->Release();
        }
        CoUninitialize();
    }
    return 0;
}
Holger
  • 3,920
  • 1
  • 13
  • 35
  • I didn't find any document or api to add to this item, also for example, in visual studio 2019> File> Open> Folder, there is no item displayed in the "virtual folder". Could you please share the reason why you want to display shortcuts in it, you can see all shortcuts you want under the left pane under the "application links" – Drake Wu Jul 10 '20 at 03:32
  • That Visual Studio has the folder empty too is a valid objection. So obviously this is how Microsoft intents it to be. *However*, I think it is pretty confusing because *all the other* top-level items on the left "shortcut" pane behave differently: They all show their sub-items when I click on them directly. When I showed my file dialog to some alpha testers, some reported the empty folder when clicking on "Application Links" as a bug. So basically I would like to avoid that my software looks buggy. – Holger Jul 10 '20 at 11:21
  • 1
    After confirming with the Internal engineer, this is by design of the Windows Common File Dialog and there is no way to customize or expand the list view on the item “Application Links”. Actually this is not a virtual folder, but it’s a kind of list of the shell folder items. Considering it’s displayed in the places bar, this may cause user confusion on the operation of the items. We suggest opening a design change request to Windows PG and modify this behavior in the future Windows release. – Drake Wu Jul 21 '20 at 09:24
  • Thanks a lot for looking into this. – Holger Jul 21 '20 at 10:41
  • We suggest that you could open the request in FeedBack Hub. – Drake Wu Aug 04 '20 at 06:14

0 Answers0