简体   繁体   English

是否可以在Windows资源管理器的“属性/详细信息”中显示的文件中添加版本号

[英]Is it possible to add a version number to a file that will be visible in Properties/Details in windows explorer

I have an unmanaged C++ project where I am writing data to a custom file format that I have defined. 我有一个非托管的C ++项目,我将数据写入我定义的自定义文件格式。

What I would like to know is if there is a way to add a header that is compatible with Windows Explorer so that a version number will be displayed, as in the example below showing a Windows font. 我想知道的是,是否有一种方法可以添加与Windows资源管理器兼容的标头,以便显示版本号,如下面显示Windows字体的示例所示。

例

The purpose of this is so that non-tech savvy users could simply right click and identify the version of the file, without having to open it in Notepad etc. 这样做的目的是让非技术娴熟的用户只需右键单击并识别文件的版本,而无需在记事本等中打开它。

Any help would be appreciated. 任何帮助,将不胜感激。

Tom 汤姆

You cannot achieve this for a file in general. 通常,您无法为文件实现此目的。 But if your file format stores a version information, you can teach the Windows Explorer to display it. 但是,如果您的文件格式存储版本信息,您可以教Windows资源管理器显示它。

You have to write a Shell Extension for the Explorer, that can extract arbitrary information out of your files. 您必须为Explorer编写Shell扩展 ,它可以从您的文件中提取任意信息。 This extension must be installed on the target computer and registered in the registry. 此扩展必须安装在目标计算机上并在注册表中注册。

An excellent guide on how to write and register Shell Extensions can be found here on CodeProject . 有关如何编写和注册Shell Extensions的优秀指南,请参见CodeProject (Part VIII should cover what you need) (第八部分应涵盖你需要的)

The version information comes from VERSIONINFO resource , attached to a binary file, such as .EXE or .DLL. 版本信息来自VERSIONINFO资源 ,附加到二进制文件,例如.EXE或.DLL。 So it is easy to link such resource into your build target, this resource is also editable. 因此很容易将此类资源链接到您的构建目标,此资源也是可编辑的。

However, this is limited to the binary executable files, and you cannot attach this resource information to arbitrary files (as you wanted), including such as text files. 但是,这仅限于二进制可执行文件,您无法将此资源信息附加到任意文件(如您所愿),包括文本文件等。

在VC中,只需转到菜单Project-> AddResource并选择Version。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM