Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

windows

I have an unmanaged C++ project where I am writing data to a custom file format that I have defined.

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.

Example

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

like image 785
TomP89 Avatar asked Oct 05 '11 10:10

TomP89


People also ask

How do I add information to file Properties?

Click the File tab. Click Info to view the document properties. To add or change properties, hover your pointer over the property you want to update and enter the information. Note that for some metadata, such as Author, you'll have to right-click on the property and choose Remove or Edit.

How do you show Properties on a file?

To view information about a file or folder, right-click it and select Properties. You can also select the file and press Alt + Enter .


2 Answers

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.

You have to write a Shell Extension for the Explorer, that can extract arbitrary information out of your files. 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. (Part VIII should cover what you need)

like image 178
Stephan Avatar answered Oct 12 '22 23:10

Stephan


The version information comes from VERSIONINFO resource, attached to a binary file, such as .EXE or .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.

like image 20
Roman R. Avatar answered Oct 12 '22 23:10

Roman R.