Win8下建立shortcut到开始界面

在win8前建立开始菜单都很容易,但到win8就有点不一样了,它的开始菜单是metro风格的。下面我们来看下具体的实现代码,有兴趣的朋友可以自己测试下。

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;

Win8下建立shortcut到开始界面

上一篇:如何解决chm类型的文件在Windows操作系统中无法打开


下一篇:C# string[ ][ ] 与string[,]