zoukankan      html  css  js  c++  java
  • 在快速启动栏和桌面创建快捷方式(代码片段)

    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;
    }
  • 相关阅读:
    unexpected inconsistency;run fsck manually esxi断电后虚拟机启动故障
    centos 安装mysql 5.7
    centos 7 卸载mysql
    centos7 在线安装mysql5.6,客户端远程连接mysql
    ubuntu 14.04配置ip和dns
    centos7 上搭建mqtt服务
    windows eclipse IDE打开当前类所在文件路径
    git 在非空文件夹clone新项目
    eclipse中java build path下 allow output folders for source folders 无法勾选,该如何解决 eclipse中java build path下 allow output folders for source folders 无法勾选,
    Eclipse Kepler中配置JadClipse
  • 原文地址:https://www.cnblogs.com/jerry1999/p/3677358.html
Copyright © 2011-2022 走看看