IShellFolder * psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop); // needed to obtain full qualified pidl

LPITEMIDLIST pidl = NULL;
#ifndef _UNICODE
OLECHAR * olePath = NULL;
olePath = (OLECHAR *) calloc (strArray.GetAt (0).GetLength () + 1, sizeof (OLECHAR)); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)strArray.GetAt (0).GetBuffer(0), -1, olePath, strArray.GetAt (0).GetLength () + 1);

 psfDesktop->ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL); free (olePath);
#else
psfDesktop->ParseDisplayName (NULL, 0, strArray.GetAt (0).GetBuffer(0), NULL, &pidl, NULL);
#endif
上面这段代码根据是否UNICODE做了处理,但是,在非UNICODE下,运行正确,但是在unicode下,也就是在下面的else里面,ParseDisplayName后,pidl始终为空。(strArray为CStringArray类型)。
哪位兄弟知道问题在哪呢??

解决方案 »

  1.   

    psfDesktop->ParseDisplayName (NULL, 0, strArray.GetAt (0).GetBuffer(256), NULL, &pidl, NULL);strArray.GetAt (0).ReleaseBuffer();
      

  2.   

    psfDesktop->ParseDisplayName (NULL, 0, strArray[0].GetBuffer(0), NULL, &pidl, NULL);
    strArray[0].ReleaseBuffer();
      

  3.   

    应该是UNICODE下,你的strArray.GetAt (0)的值不正确.这个问题和ParseDisplayName应该无关.
    你可以设一个断点看看strArray.GetAt (0)的值(当然了,要转换为char来看).
      

  4.   

    strArray.GetAt (0)的值是正确的啊,楼上的办法都没的解决
    郁闷也