代码之家  ›  专栏  ›  技术社区  ›  Mohammed Nasman

使用Delphi创建Win7跳转列表[关闭]

  •  7
  • Mohammed Nasman  · 技术社区  · 15 年前

    我正在尝试使用Delphi在Windows7上为我的应用程序创建跳转列表。

    我找到了这个C++代码,但是我不知道如何把它翻译成Delphi,有什么帮助吗?

         void CreateJumpList()    
        {        
            ICustomDestinationList *pcdl;    
            HRESULT hr = CoCreateInstance    
                           (CLSID_DestinationList,     
                            NULL, CLSCTX_INPROC_SERVER,    
           IID_PPV_ARGS(&pcdl));          
    
             if (SUCCEEDED(hr))     
           {    
               hr = pcdl->SetAppID(c_szAppID);    
                if (SUCCEEDED(hr))    
                {    
                    UINT uMaxSlots;    
                    IObjectArray *poaRemoved;
                        hr = pcdl->BeginList    
                        (&uMaxSlots, IID_PPV_ARGS(&poaRemoved));    
                    if (SUCCEEDED(hr))    
                    {
    
                        hr = _AddCategoryToList(pcdl, poaRemoved);    
                        if (SUCCEEDED(hr))    
                        {    
                            pcdl->CommitList();    
                        }    
                        poaRemoved->Release();    
                    }    
                }    
            }    
        }
    
    // This is the helper function that actually 
    
    //appends the items to a collection object HRESULT 
    
    
    _AddCategoryToList(ICustomDestinationList *pcdl,    
                           IObjectArray *poaRemoved)    
    {
        IObjectCollection *poc;    
        HRESULT hr = CoCreateInstance    
    (CLSID_EnumerableObjectCollection,     
    NULL,     
    CLSCTX_INPROC_SERVER,     
    IID_PPV_ARGS(&poc));    
        if (SUCCEEDED(hr))    
        {    
            for (UINT i = 0; i < ARRAYSIZE(c_rgpszFiles); i++)    
            {    
                IShellItem *psi;    
                if (SUCCEEDED(SHCreateItemInKnownFolder(    
    FOLDERID_Documents,     
    KF_FLAG_DEFAULT,     
    c_rgpszFiles[i],     
    IID_PPV_ARGS(&psi))))    
                {    
                    if(!_IsItemInArray(psi, poaRemoved))    
                    {    
                        poc->AddObject(psi);    
                    }    
                    psi->Release();
                }    
            }
    
            IObjectArray *poa;    
            hr = poc->QueryInterface(IID_PPV_ARGS(&poa));    
            if (SUCCEEDED(hr))    
            {    
                pcdl->AppendCategory(L"Custom category", poa);    
                poa->Release();    
            }    
            poc->Release();    
        }    
        return hr;    
    }
    
    0 回复  |  直到 15 年前