Possible to add tags to custom file?

452 views Asked by At

For MS Office files, like a docx file, image files etc you can set searchable tags from properties in Windows Explorer, see image.

Defining tags

If I have my own custom file format, how can I add that to the details page of my file? I've been looking at shell extensions, but that doesn't seem to be the way to go. My custom file format is a compound file, so basically a zip archive.

And if it is a shell extension that I should use to enable that for my own custom file, then please which one is it? I've been looking at "The Complete Idiot's Guide to Writing Shell Extensions" but I didn't find anything there, only how to add a new property page.

I'm using MFC.

Thanks!

1

There are 1 answers

0
Denis Anisimov On BEST ANSWER

For Vista and later:

1) Create shell extension implements IPropertyStore, IPropertyStoreCapabilities and IInitializeWithStream. if your cannot work with stream implement IInitializeWithFile instead of IInitializeWithStream. A lot of details.

2) IPropertyStore.GetCount must return number of properties you need. In case you described it must return 1.

3) IPropertyStore.GetAt must return PKEY of your properties. In case you described it must return PKEY_Keywords.

4) Inside IPropertyStore.GetValue you must read your Tags from your zip file and return them in function result.

5) Inside IPropertyStore.SetValue you must store new value in internal memory storage.

6) Inside IPropertyStore.Commin you must store new value from internal memory storage to your real zip file.

7) IPropertyStoreCapabilities.IsPropertyWritable must return S_OK if you want user to edit your property.

8) Create reg value:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.myzip]
"FullDetails"="prop:System.PropGroup.Description;System.Keywords;System.PropGroup.FileSystem;System.ItemNameDisplay;System.ItemTypeText;System.ItemFolderPathDisplay;System.Size;System.DateCreated;System.DateModified;System.FileAttributes;*System.OfflineAvailability;*System.OfflineStatus;*System.SharedWith;*System.FileOwner;*System.ComputerName"

You can try to replace HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations.myzip with HKEY_CLASSES_ROOT.myzip. Don`t forget to change .myzip to your extension.

9) Enjoy the result:

Custom property

For XP:

1) Create shell extension implements IColumnProvider. Part VIII of The Complete Idiot's Guide to Writing Shell Extensions.

2) If you want user to edit your Tags you must create Property Sheet shell extension.