Currently, my property handler provides properties that can be displayed in Windows Explorer columns of type String
. My goal is to extend the handler by a property of (display) type Icon, that can be added as a column to the details view of Windows Explorer. In this column, an icon should be displayed for each file item, e. g. the icon could represent a specific state of the file out of several possible states.
However, I did not manage to assemble the necessary parts of creating a property with these characteristics on the base of the Windows Property System correctly.
The first step of my approach is to specify the XML for the property in a .propdesc file and then go through the usual PSRegisterPropertySchema
registration process. This runs always successfully and the property is listed in the Windows Property System.
<propertyDescription name="myprop.icon" formatID="{c5f47221-1053-4a75-aadc-0bfbac1c3e9c}" propID="444">
<typeInfo type="???" isInnate="true" isViewable="true"/>
<labelInfo label="MyProp-Icon"/>
<displayInfo defaultColumnWidth="25" alignment="Center">
<drawControl control="IconList"/>
</displayInfo>
</propertyDescription>
The existence of <drawControl>
(drawControl) with a control
attribute of type "IconList"
within the <displayInfo>
tag makes me feel that my idea could be feasible.
But how to set the corresponding type
in the <typeInfo>
tag (typeInfo)? Depending on the concept of control="IconList"
this could be an integer as an index
into somewhat like an imagelist. Or is it a "Buffer"
, "Blob"
or "Stream"
representing the image itself?
Last, in the GetValue()
method of the Property Handler shell extension the PROPVARIANT
has to be initialized according to the property description of the .propdesc file:
HRESULT PropertyHandler::GetValue (REFPROPERTYKEY key, PROPVARIANT *pPropVar)
{
HRESULT hr = ERROR_NOT_FOUND;
if (key.pid == 444)
{
// How to initialize pPropVar in case of control="IconList"?
}
else
{
// String example
hr = InitPropVariantFromString (L"Some Text", pPropVar);
}
return hr;
}
Again, how to do this for "IconList"
properties?
Each attempt to find a correct match between the XML specification and the PROPVARIANT initialization leaves the corresponding column in Windows Explorer blank.
Does anybody already implemented a property with a <drawControl>
of type IconList
?
There is WINDOWSPROPERTYDESCRIPTIONS resource inside propsys.dll. This resource describes all system props. Some of properties have drawcontrol equal to IconList. Example:
ALL of such props have type equal to "Blob". So Blob is answer.
Update
My little investigation.
The only known (by me) handler that shows icons is OneDrive. Screenshot:
I got value of System.StorageProviderUIStatus property of one of OneDrive files. Value dump:
As you see this is not image or icon. This is Property Store Binary File described in [MS-PROPSTORE]. Decoded form:
Binary data in embedded Property Store Binary File. Its decoded form:
Everything looks quite hard for simple icon description. And maybe I`am wrong and Blob type is not the only answer.
SOLUTION
Content of propdesc file:
When shell request DummyUIState you must create blob with Property Store Binary File. Property Store Binary File must contain the following data:
That's all. Tested on Windows 10. Screenshot: