I tried looking this on SO but all the questions that attempt to answer do not provide a full answer.
I actually want to add a property to the details tab of an existing the file. File is of the sldprt extension. The property/value has to be visible in Windows Explorer.
Not sure how this be done with Windows API Code Pack Shell or DSOFile? Any other solution is fine too.
I'm using VS, C# on Windows 10.
If someone could provide a detailed solution, I would be very thankful.
The perfect solution would:
- Add the property to the file through dsofile, ADS, or whatever means possible.
- Edit to Windows Registery or whatever part of Windows that is responsible for showing the new property in the details tab of the file properties and in Windows Explorer
- Show how the property's value can be edited.
This answer of this question does not add attributes to the details tab nor Windows Explorer detailed view.
I think it's possible since SOLIDWORKS (3d package) adds a property called sw last saved with to all SOLIDWORKS files. There are tons of other properties in the details window.
Please if you don't have the right solution, do not answer. Thank you very much.
I'm not sure this question is a duplicate of Add new metadata properties to a file.
Previews:
Edit:
Registery for the sldprt extension (for reference purpose):



The details tab in the properties window is populated with metadata property handlers. The metadata property system is something Microsoft introduced with Windows Vista and it was made open and extensible, enabling independent developers (like Solidworks) to implement and support their own file properties. Very roughly, the flow of execution is something like this:
Property handlers are COM objects. COM (Component Object Model) is Microsoft's attempt at a language-independent object oriented framework whose origins go all the way back to the nineties, but for the purposes of this explanation suffice it to say that a COM object is a C++ class that implements the
IUnknowninterface. A property handler has to implement theIPropertyStoreinterface on top of that:A convenience implementation of this interface is
CLSID_InMemoryPropertyStoreprovided to developers to ease their own implementation ofIPropertyStore. The interesting methods here areGetValueandSetValue. Properties are assigned a unique GUID, which thePROPERTYKEYstructure passed into these functions contains to identify the property. The implementations details forGetValueandSetValueare left to the developer, so it is up to the developer how and where to store the value for each property -- these values could be stored in another file, in an alternate file stream, or in the registry to name a few options -- but for transportability reasons it is recommended to store the values in the file itself. This way, if the file is zipped up and emailed, for example, the properties go with it.The property handler COM object is compiled into a DLL and registered with the system with
regsvr32. This allows Windows to know where to go look for properties for that specific file format. Once registered, the property handler can be obtained in a number of ways, one of which is the convenience functionSHGetPropertyStoreFromParsingName:Once obtained,
GetValueandSetValuecan be invoked on theIPropertyStoreobject to either obtain, change or set new value for a property. If usingSetValuethough, make sure to invokeCommitas well.Microsoft provides a utility, called
PropertyEdit, to get and set metadata properties on a file as part of their Windows Classic Samples. It's a shame they don't mention it anywhere in their help pages. Since you already have Solidworks installed, the property handler for the file formats you're interested in should already be registered on the system and it should be a matter of compilingPropertyEditand using it to get and set the metadata properties the handler supports. It's a simple command line utility.If you need, or want to support custom metadata for your own file format, there is a full-blown sample property handler as well:
RecipePropertyHandler.For reference, to set a property by its canonical name: