如何转换到一个 ITEMIDLIST 文件路径

来源:互联网 发布:cnki专利数据库 编辑:程序博客网 时间:2024/05/16 12:15

如何转换到一个 ITEMIDLIST 文件路径

注意:这篇文章是由无人工介入的自动的机器翻译系统翻译完成。这些文章是微软为不懂英语的用户提供的, 以使他们能够理解这些文章的内容。微软不保证机器翻译的正确度,也不对由于内容的误译或者客户对它的使用所引起的任何直接的, 或间接的可能的问题负责。
文章编号 : 132750 最后修改 : 2005年7月11日 修订 : 1.3

概要

开发应用程序与 WindowsExplorer 外壳程序, 交互时您可能需要转换到文件以一个 ITEMIDLIST 任意路径。 您可以使用 IShellFolder::ParseDisplayName API。

更多信息

下面是如何使用 IShellFolder 接口要转换为当前目录以一个 ITEMIDLIST 中 Readme.txt 文件路径的示例。 是用 C 编写示例 如果使用 VisualC++, 写入程序通过 lpVtbl 变量访问成员函数没有必要。
   LPITEMIDLIST  pidl;   LPSHELLFOLDER pDesktopFolder;   char          szPath[MAX_PATH];   OLECHAR       olePath[MAX_PATH];   ULONG         chEaten;   ULONG         dwAttributes;   HRESULT       hr;   //    // Get the path to the file we need to convert.   //    GetCurrentDirectory(MAX_PATH, szPath);   lstrcat(szPath, "//readme.txt");   //    // Get a pointer to the Desktop's IShellFolder interface.   //    if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))   {       //        // IShellFolder::ParseDisplayName requires the file name be in       // Unicode.       //        MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1,                           olePath, MAX_PATH);       //        // Convert the path to an ITEMIDLIST.       //        hr = pDesktopFolder->lpVtbl->ParseDisplayName(pDesktopFolder,                                                     NULL,                                                     NULL,                                                     olePath,                                                     &chEaten,                                                     &pidl,                                                     &dwAttributes);       if (FAILED(hr))       {           // Handle error.       }       //        // pidl now contains a pointer to an ITEMIDLIST for ./readme.txt.       // This ITEMIDLIST needs to be freed using the IMalloc allocator       // returned from SHGetMalloc().       //        //release the desktop folder object         pDesktopFolder->lpVtbl->Release();   }
原文地址:http://support.microsoft.com/kb/132750/zh-cn
 
原创粉丝点击