Windows 文件预览 - 类似于资源管理器中的预览窗格
在 Windows 7(我认为是 Vista)中,资源管理器有一个预览窗格,可让您查看某些文件类型(MS Office、图像等)的内容。是否有任何 API 可以让您访问此功能?
我一直在使用 WindowsAPICodePack ,它有一个 ShellFile.Thumbnail,但这似乎只暴露了Explorer 能够查看的文件类型的缩略图图标。例如,对于 Word 文件,它仅显示 MS Word 图标,资源管理器实际上可以在其中预览文件的内容。它确实像我想要的图像类型一样工作,但不适用于其他类型的文件。
In Windows 7 (and I think Vista) the Explorer has a preview pane that lets you see the contents for some file types (MS Office, images, etc). Is there any API available that allows you to access this functionality?
I've been using the WindowsAPICodePack which has a ShellFile.Thumbnail, but this seems to only expose the thumbnail icon for file types that Explorer is able to view. For instance, for a Word file it only displays the MS Word icon, where Explorer can actually preview the contents of the file. It does work like I want for image types, but not for other types of files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
IPreviewHandler
IPreviewHandler
示例代码(虽然很难阅读......必须突出显示文本)位于:在 winform 应用程序中托管 vista/office 2007 预览器
Sample code (though hard to read... have to highlight the text) is here: Hosting vista/office 2007 previewers in winform application
对于简单的文本预览,您还可以添加注册表项
对于更复杂的内容,Microsoft 提供了 Shell 接口 IPreviewHandler [MSDN],您可以将其实现为 COM 对象以提供自定义预览。还有一个 C++ 示例 [MSDN] 可用。
该对象将通过 IInitializeWithFile 初始化[MSDN] 或 IInitializeWithStream [MSDN]
实现后,您需要在您的系统 [MSDN] 上注册它以获取不同的文件类型,如下所示:
For simple text previews you can also add a Registry key
For more complex stuff, Microsoft provides the Shell Interface IPreviewHandler [MSDN] that you can implement as a COM object to provide a custom preview. There is a C++ example [MSDN] available as well.
The object will be initialized via IInitializeWithFile [MSDN] or IInitializeWithStream [MSDN]
Once you implemented it, you need to register it on your system [MSDN] for different file type like this:
可以在 此处找到基于 IPreviewHandler 的 .Net 商业现成预览控件。
A commercial ready-to-use preview control for .Net based on IPreviewHandler can be found here.