How to fill the virtual folder "Application Links" in a Windows file dialog?

192 Views Asked by At

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;
}
0

There are 0 best solutions below