Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带QT应用程序的Windows 7跳转列表_Qt_Windows 7_Jump List - Fatal编程技术网

带QT应用程序的Windows 7跳转列表

带QT应用程序的Windows 7跳转列表,qt,windows-7,jump-list,Qt,Windows 7,Jump List,我正在尝试用QT应用程序开发windows7跳转列表。我有 已创建跳转列表任务退出。我想结束我的申请 单击此跳转列表任务将退出。怎么做 IShellLink* CreateShellLink(QString title, QString description, QString app_path, QString app_args, QString icon_path, int app_index) { IShellLink* shell_link = NULL; IPropertyStore

我正在尝试用QT应用程序开发windows7跳转列表。我有 已创建跳转列表任务退出。我想结束我的申请 单击此跳转列表任务将退出。怎么做

IShellLink* CreateShellLink(QString title, QString description,
QString app_path, QString app_args,
QString icon_path, int app_index)  {
IShellLink* shell_link = NULL;
IPropertyStore* prop_store = NULL;
bool is_not_separator = (app_path.length() > 0);

HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
reinterpret_cast<void**> (&(shell_link)));

if(SUCCEEDED(hr)) {

if (is_not_separator) {
// Set the path and file name of the shell link object
shell_link->SetPath(app_path.toStdWString().c_str());
// Set the command-line arguments for the shell link object
shell_link->SetArguments(app_args.toStdWString().c_str());
shell_link->SetIconLocation(icon_path.toStdWString().c_str(), app_index);
shell_link->SetDescription(description.toStdWString().c_str());

//shell_link->
}

// Set the name of the shell link object
hr = shell_link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void**> (&(prop_store)));

if (SUCCEEDED(hr)) {
PROPVARIANT pv;

if (is_not_separator) {
hr = InitPropVariantFromString(title.toStdWString().c_str(), &pv);

if (SUCCEEDED(hr)) {
hr = prop_store->SetValue(PKEY_Title, pv);
}
} else {
hr = InitPropVariantFromBoolean(TRUE, &pv);

if (SUCCEEDED(hr)) {
hr = prop_store->SetValue(PKEY_AppUserModel_IsDestListSeparator, pv);
}
}

//Save the changes we made to the property store
prop_store->Commit();
prop_store->Release();

PropVariantClear(&pv);
}
}

return shell_link;
}

void AddTasksToList(ICustomDestinationList* destinationList) {
IObjectArray* object_array;
IObjectCollection* obj_collection;

// Creating a new category on Browser's Jump List
CoCreateInstance(CLSID_EnumerableObjectCollection, NULL,
CLSCTX_INPROC, IID_IObjectCollection, reinterpret_cast<void**> (&(obj_collection)));

obj_collection->QueryInterface(IID_IObjectArray, reinterpret_cast<void**> (&(object_array)));

QString icons_source("C:\\windows\\explorer.exe");
QString app_path = qApp->applicationFilePath();

obj_collection->AddObject(CreateShellLink("Quit", "Description Task 1",
app_path, "-auto",
icons_source, 20));

// Add the specified user task to the Task category of a Jump List
destinationList->AddUserTasks(object_array);

object_array->Release();
obj_collection->Release();
}

void SetupJumpList() {
UINT max_count = 0;
IObjectArray* objectArray;
ICustomDestinationList* destinationList;

//create the custom jump list object
CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList,
reinterpret_cast<void**> (&(destinationList)));

//initialize list
destinationList->BeginList(&max_count, IID_IObjectArray, reinterpret_cast<void**> (&(objectArray)));
AddTasksToList(destinationList);

//commit list
destinationList->CommitList();
objectArray->Release();
destinationList->Release();
}