예제 #1
0
void CWin7::CreateTasksList()
{
	if ( m_DestList )
	{
		if ( m_List )
		{
			IObjectCollection *poc;
			HRESULT hr = CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&poc));
			if (SUCCEEDED(hr))
			{
				IShellLink * psl;

				hr = _CreateShellLink("/Tab-Favs", L"Favourites", "Open Favourites Tab", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}
				hr = _CreateShellLink("/Tab-Internet", L"Internet", "Open Internet Tab", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}
				hr = _CreateShellLink("/Tab-Official", L"Official", "Open Official Tab", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}
#ifndef _NO_HISTORY
				hr = _CreateShellLink("/Tab-History", L"History", "Open History Tab", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}
#endif
#ifndef _NO_LAN_MODE
				hr = _CreateShellLink("/Tab-Lan", L"LAN", "Open LAN Tab", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}
#endif

				if (SUCCEEDED(hr))
				{
					hr = _CreateSeparatorLink(&psl);
					if (SUCCEEDED(hr))
					{
						hr = poc->AddObject(psl);
						psl->Release();
					}
				}

				hr = _CreateShellLink("/Win-Settings", L"Settings", "Open the Settings dialog", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}

				hr = _CreateShellLink("/Win-Help", L"Help", "Get Help & Support and the forums", &psl);
				if (SUCCEEDED(hr))
				{
					hr = poc->AddObject(psl);
					psl->Release();
				}

				if (SUCCEEDED(hr))
				{
					IObjectArray * poa;
					hr = poc->QueryInterface(IID_PPV_ARGS(&poa));
					if (SUCCEEDED(hr))
					{
						// Add the tasks to the Jump List. Tasks always appear in the canonical "Tasks"
						// category that is displayed at the bottom of the Jump List, after all other
						// categories.
						hr = m_DestList->AddUserTasks(poa);
						poa->Release();
					}
				}

				poc->Release();
			}
		}
	}
}
// Builds the collection of task items and adds them to the Task section of the Jump List.  All tasks
// should be added to the canonical "Tasks" category by calling ICustomDestinationList::AddUserTasks.
HRESULT _AddTasksToList(ICustomDestinationList *pcdl)
{
    IObjectCollection *poc;
    HRESULT hr = CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&poc));
    if (SUCCEEDED(hr))
    {
        IShellLink * psl;
        hr = _CreateShellLink(L"/Task1", L"Task 1", &psl);
        if (SUCCEEDED(hr))
        {
            hr = poc->AddObject(psl);
            psl->Release();
        }

        if (SUCCEEDED(hr))
        {
            hr = _CreateShellLink(L"/Task2", L"Second Task", &psl);
            if (SUCCEEDED(hr))
            {
                hr = poc->AddObject(psl);
                psl->Release();
            }
        }

        if (SUCCEEDED(hr))
        {
            hr = _CreateSeparatorLink(&psl);
            if (SUCCEEDED(hr))
            {
                hr = poc->AddObject(psl);
                psl->Release();
            }
        }

        if (SUCCEEDED(hr))
        {
            hr = _CreateShellLink(L"/Task3", L"Task 3", &psl);
            if (SUCCEEDED(hr))
            {
                hr = poc->AddObject(psl);
                psl->Release();
            }
        }

        if (SUCCEEDED(hr))
        {
            IObjectArray * poa;
            hr = poc->QueryInterface(IID_PPV_ARGS(&poa));
            if (SUCCEEDED(hr))
            {
                // Add the tasks to the Jump List. Tasks always appear in the canonical "Tasks"
                // category that is displayed at the bottom of the Jump List, after all other
                // categories.
                hr = pcdl->AddUserTasks(poa);
                poa->Release();
            }
        }
        poc->Release();
    }
    return hr;
}