您当前的位置: 首页 > 

蓝不蓝编程

暂无认证

  • 4浏览

    0关注

    706博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

在快速启动栏和桌面创建快捷方式(代码片段)

蓝不蓝编程 发布时间:2012-04-22 14:25:42 ,浏览量:4

bool CreateQuickLaunchShortcut(String& destFile,String& shortCutName,String& arguments) {     char szBuf[MAX_PATH]; LPITEMIDLIST lpItemIdList; SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &lpItemIdList); SHGetPathFromIDList(lpItemIdList, szBuf); String dir = String(szBuf) + "\\Microsoft\\Internet Explorer\\Quick Launch\\"; bool result = CreateShortcut(destFile,shortCutName,dir,arguments); return result; } bool CreateShortcut(String& destFile,String& shortCutName,String& dir,String& arguments) { TShortcutCfg scConfig; scConfig.strDestFile = destFile; scConfig.strShortcutName = shortCutName; scConfig.strArguments = arguments; bool bReturn = true;     wchar_t wszBuf[MAX_PATH];     IShellLink *pShellLink; AnsiString strShortcutFile; strShortcutFile = dir + shortCutName + SHORTCUT_SUFFIX; strShortcutFile.WideChar(wszBuf, MAX_PATH);     if(bReturn)     {         bReturn = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,                 IID_IShellLink, (void **)&pShellLink) >= 0;         if(bReturn)         {             IPersistFile *ppf;             bReturn = pShellLink->QueryInterface(IID_IPersistFile, (void **)&ppf) >= 0;             if(bReturn)             {                 // 目标文件 if(scConfig.strDestFile != EmptyStr) bReturn = pShellLink->SetPath(scConfig.strDestFile.c_str()) >= 0;                 // 参数                 if(bReturn && scConfig.strArguments != EmptyStr)                  bReturn = pShellLink->SetArguments(scConfig.strArguments.c_str()) >= 0;                 // 显示图标                 if(bReturn && scConfig.strIconFile != EmptyStr && FileExists(scConfig.strIconFile))                     pShellLink->SetIconLocation(scConfig.strIconFile.c_str(),                             scConfig.nIconIndex);                 // 起始位置                 if(bReturn && scConfig.strWorkingDir != EmptyStr)                     pShellLink->SetWorkingDirectory(scConfig.strWorkingDir.c_str());                 // 备注                 if(bReturn && scConfig.strDescription != EmptyStr)                     pShellLink->SetDescription(scConfig.strDescription.c_str());                 // 快捷键                 if(bReturn && scConfig.wHotKey != 0)                     pShellLink->SetHotkey(scConfig.wHotKey);                 // 运行方式                 if(bReturn && scConfig.nShowCmd != 0)                     pShellLink->SetShowCmd(scConfig.nShowCmd);                 if(bReturn)                     bReturn = (ppf->Save(wszBuf, TRUE) >= 0);                 ppf->Release ();             }             pShellLink->Release ();         }     }     return bReturn; }
关注
打赏
1639405877
查看更多评论
立即登录/注册

微信扫码登录

0.0985s