1、如何得到桌面图标的LIST。
2、如何更改图标,如:更改桌面上一个快捷方式的图标。
最好能给个例子。谢谢!

解决方案 »

  1.   

    1. 通过SHGetFolderPath(CSIDL_DESKTOPDIRECTORY)取得桌面的路径
    2. 枚举该目录内文件(一般是.lnk文件)
    3. 分析快捷方式文件(CSDN上有很多文章关于快捷方式,搜索IShellLink),可以取得icon和修改icon
      

  2.   

    1、可能先需要知道桌面的快捷方式保存在什么地方,然后才能获得之。
    2、参考:
    创建快捷方式
    HRESULT CreateLink(LPCSTR lpszPathObj,
                LPSTR lpszPathLink,
                LPSTR lpszDesc) 
    {
        HRESULT hres;
        IShellLink* psl;
        CoInitialize(NULL);
        // Get a pointer to the IShellLink interface. 
        hres = CoCreateInstance(CLSID_ShellLink, NULL,
            CLSCTX_INPROC_SERVER,
            IID_IShellLink,
            (void **)&psl); 
        
        if (SUCCEEDED(hres))
        {
            IPersistFile* ppf;
            // Set the path to the shortcut target and add the 
            // description.
            psl->SetPath(lpszPathObj);
            psl->SetDescription(lpszDesc);
            // Query IShellLink for the IPersistFile interface for saving the 
            // shortcut in persistent storage. 
        hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
                if (SUCCEEDED(hres))
                { 
            WORD wsz[MAX_PATH]; // Ensure that the string is ANSI. 
            MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1,wsz, MAX_PATH); 
            // Save the link by calling IPersistFile::Save. 
            hres = ppf->Save(wsz, TRUE);
                ppf->Release();
                } 
        psl->Release();
        }
        return hres;
    }
      

  3.   

    roger_ding(海天一色)
    枚举该目录内文件(一般是.lnk文件)通过什么函数来实现枚举?char s[255];
    SHGetSpecialFolderPath(this->m_hWnd,s,CSIDL_DESKTOPDIRECTORY,TRUE);我通过上面获得了DESKTOP的目录,也找到了IShellLink的相关文章。
    帮忙解释一下!
      

  4.   

    IShellLink可以解析出快捷方式的文件及icon,如果想取得icon,用ExtractIconEx,至于设置icon,自己钻研MSDN吧