Когда я создаю диалоговое окно с обычным файлом на Windows, я могу добавить ярлыки c для конкретных приложений на левой панели с помощью IFileDialog :: AddPlace .
Все ярлыки отображаются в виртуальной папке с названием «Ссылки на приложения». Но когда я нажимаю «Ссылки на приложения», папка кажется пустой, показывая только «Нет элементов, соответствующих вашему запросу»:
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;
}