zoukankan      html  css  js  c++  java
  • Win8下建立shortcut到開始界面

    在win8前建立開始菜单都非常easy,但到win8就有点不一样了。它的開始菜单是metro风格的。以下我们来看下详细的实现代码。有兴趣的朋友能够自己測试下,它的作用是设置shortcut到metro start menu.  假设是要阻止到start menu的话,把APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL改为PKEY_AppUserModel_PreventPinning。

    void SetShortcutStartPinOption()

    {

    wchar_t szPath[MAX_PATH];

    SHGetSpecialFolderPath(nullptr, szPath, CSIDL_PROGRAMS, FALSE);
    PathAppend(szPath, L"testapp.lnk");
    int nRet = 1;
    // initialize the COM library
    CoInitialize(NULL);


    IPropertyStore *pps;
    if (SUCCEEDED(SHGetPropertyStoreFromParsingName(szPath, NULL, GPS_READWRITE, __uuidof(IPropertyStore), (void**)&pps)))
    {
    PROPVARIANT pv;

    // --- Set StartPinOption.
    if (SUCCEEDED(pps->GetValue(PKEY_AppUserModel_StartPinOption, &pv)))
    {

    if (SUCCEEDED(InitPropVariantFromUInt32(APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL, &pv)))
    {

    if (SUCCEEDED(pps->SetValue(PKEY_AppUserModel_StartPinOption, pv)))
    {

    if (SUCCEEDED(pps->Commit()))
    {
    nRet = 0;
    }
    }
    }
    }
    }

    if (pps != NULL)
    pps->Release();
    CoUninitialize();
    return nRet;

    }

  • 相关阅读:
    文件上传
    大三寒假学习进度笔记Day16
    大三寒假学习进度笔记Day15
    大三寒假学习进度笔记Day14
    大三寒假学习进度笔记Day13
    大三寒假学习进度笔记Day12
    大三寒假学习进度笔记Day11
    大三寒假学习进度笔记Day10
    Java命名规范
    架构漫谈阅读笔记03
  • 原文地址:https://www.cnblogs.com/mthoutai/p/6922497.html
Copyright © 2011-2022 走看看