title: How to create an IconList property in the Windows Property System?
body: <p>Currently, my property handler provides properties that can be displayed in Windows Explorer columns of type <code>String</code>. My goal is to extend the handler by a property of (display) type <em>Icon</em>, 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.</p>
  
  <p>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.</p>
  
  <p>The first step of my approach is to specify the XML for the property in a <em>.propdesc</em> file and then go through the usual <code>PSRegisterPropertySchema</code> registration process. This runs always successfully and the property is listed in the Windows Property System.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;propertyDescription name="myprop.icon" formatID="{c5f47221-1053-4a75-aadc-0bfbac1c3e9c}" propID="444"&gt;
      &lt;typeInfo type="???" isInnate="true" isViewable="true"/&gt;
      &lt;labelInfo label="MyProp-Icon"/&gt;
      &lt;displayInfo defaultColumnWidth="25" alignment="Center"&gt;
          &lt;drawControl control="IconList"/&gt;
      &lt;/displayInfo&gt;
  &lt;/propertyDescription&gt;
  </code></pre>
  
  <p>The existence of <code>&lt;drawControl&gt;</code> (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb773866(v=vs.85).aspx" rel="noreferrer">drawControl</a>) with a <code>control</code> attribute of type <code>"IconList"</code> within the <code>&lt;displayInfo&gt;</code> tag makes me feel that my idea could be feasible.</p>
  
  <p>But how to set the corresponding <code>type</code> in the <code>&lt;typeInfo&gt;</code> tag (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb773889(v=vs.85).aspx" rel="noreferrer">typeInfo</a>)? Depending on the concept of <code>control="IconList"</code> this could be an integer as an index
  into somewhat like an imagelist. Or is it a <code>"Buffer"</code>, <code>"Blob"</code> or <code>"Stream"</code> representing the image itself?</p>
  
  <p>Last, in the <code>GetValue()</code> method of the Property Handler shell extension the <code>PROPVARIANT</code> has to be initialized according to the property description of the <em>.propdesc</em> file:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>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;
  }
  </code></pre>
  
  <p>Again, how to do this for <code>"IconList"</code> properties?</p>
  
  <p>Each attempt to find a correct match between the XML specification and the PROPVARIANT initialization leaves the corresponding column in Windows Explorer blank.</p>
  
  <p>Does anybody already implemented a property with a <code>&lt;drawControl&gt;</code> of type <code>IconList</code>?</p>