使用Delphi创建Win7跳转列表 [英] Using Delphi to creating Win7 Jump list
本文介绍了使用Delphi创建Win7跳转列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在我的应用程序使用Delphi在Windows 7上创建跳转列表。
I'm trying to create Jump list on windows 7 for my application using Delphi.
我发现这个c ++代码,但我不知道如何翻译它到Delphi,任何帮助?
I found this c++ code, but I'm not sure how to translate it to Delp any help?
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;
}
推荐答案
用于制作Windows 7跳转列表。它使用与您在C ++示例中提供的相同的Windows API,但是转换为Delphi: http://delphi32.blogspot.com/2011/05/adding-windows-7-jump-list-to-delphi.html
There is a Delphi 2010 library for making the Windows 7 Jump Lists. It uses the same Windows API which your provided in your C++ sample, but translated to Delphi: http://delphi32.blogspot.com/2011/05/adding-windows-7-jump-list-to-delphi.html
用法很简单:
var
Item : TJumpTask;
begin
Item := TJumpTask.Create;
Item.Title := 'Custom Task';
Item.ApplicationPath := ParamStr(0);
Item.Arguments := '/doit';
Item.CustomCategory := 'Custom Category';
JumpList.JumpItems.Add(Item);
JumpList.Apply;
end;
这篇关于使用Delphi创建Win7跳转列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文