解决方案 »

  1.   

    应该有windows接口可做到,我没研究过。
    但为做过类型的,直接分析lnk文件,查找“:\”字符串。
    可参考:
    为快捷方式文件(lnk文件)右键菜单添加“打开所在文件夹”
      

  2.   

    给你个我收藏的函数//inFile是快捷方式文件名
    //返回快捷方式所指向的文件名
    CString   ExpandShortcut(CString   &inFile)
    {
        CString   outFile   =   _T(" ");    //   Make   sure   we   have   a   path
        ASSERT(inFile   !=   _T( ""));    IShellLink*   psl;
        HRESULT   hres;
        LPTSTR   lpsz   =   inFile.GetBuffer(MAX_PATH);    //   Create   instance   for   shell   link
        hres   =   ::CoCreateInstance(CLSID_ShellLink,   NULL,   CLSCTX_INPROC_SERVER,
                                      IID_IShellLink,   (LPVOID*)   &psl);
        if   (SUCCEEDED(hres)) {
            //   Get   a   pointer   to   the   persist   file   interface
            IPersistFile*   ppf;
            hres   =   psl-> QueryInterface(IID_IPersistFile,   (LPVOID*)   &ppf);
            if   (SUCCEEDED(hres)) {
                //   Make   sure   it 's   ANSI
    #ifndef _UNICODE
                wchar_t   wsz[MAX_PATH];
                ::MultiByteToWideChar(CP_ACP,   0,   lpsz,   -1,   wsz,   MAX_PATH);            //   Load   shortcut
                hres   =   ppf-> Load(wsz,   STGM_READ);
    #else
                hres   =   ppf-> Load(lpsz,   STGM_READ);
    #endif
                if   (SUCCEEDED(hres))   {
                    WIN32_FIND_DATA   wfd;
                    //   find   the   path   from   that
                    HRESULT   hres   =   psl-> GetPath(outFile.GetBuffer(MAX_PATH),
                                                       MAX_PATH,
                                                       &wfd,
                                                       SLGP_UNCPRIORITY);                outFile.ReleaseBuffer();
                }
                ppf-> Release();
            }
            psl-> Release();
        }    inFile.ReleaseBuffer();    //   if   this   fails,   outFile   ==   " "
        return   outFile;
    }