// // Create a task and add it to the jump list // HRESULT JumpList::CreateUserTask(const wchar_t* applicationPath, const wchar_t* title, const wchar_t* commandLine) { ComPtr<IObjectCollection> shellObjectCollection; HRESULT hr = CoCreateInstance(CLSID_EnumerableObjectCollection, nullptr, CLSCTX_INPROC, IID_PPV_ARGS(&shellObjectCollection)); if (SUCCEEDED(hr)) { // Create shell link first ComPtr<IShellLink> shellLink; hr = CreateShellLink(applicationPath, title, commandLine, &shellLink); if (SUCCEEDED(hr)) { hr = shellObjectCollection->AddObject(shellLink); } // Add the specified user task to the Task category of a jump list if (SUCCEEDED(hr)) { ComPtr<IObjectArray> userTask; hr = shellObjectCollection->QueryInterface(&userTask); if (SUCCEEDED(hr)) { hr = m_destinationList->AddUserTasks(userTask); } } } return hr; }
HRESULT ShellItemsLoader::CreateScope(IShellItem* currentBrowseLocation, IShellItemArray **shellItemArray) { *shellItemArray = nullptr; ComPtr<IObjectCollection> shellObjects; ComPtr<IShellLibrary> shellLibrary; HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLibrary)); if (SUCCEEDED(hr)) { hr = shellLibrary->GetFolders(LFF_FORCEFILESYSTEM, IID_PPV_ARGS(&shellObjects)); } if (SUCCEEDED(hr)) { hr = shellObjects->AddObject(currentBrowseLocation); } if (SUCCEEDED(hr)) { hr = shellObjects.QueryInterface(shellItemArray); } return hr; }