title: What are Windows clipboard CF_ formats like -16230, -15835, -15834, etc?
body: <p>All formats I could find were <a href="https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats" rel="nofollow noreferrer">these in the MS documentation</a>. When trying to implement file drag and drop (from my application to Windows' File Explorer), I get lots of <code>GetData</code> requests for <code>cfFormat</code> values like -16230, -15835, -15834, but I do not know what they are.</p>
  
  <p>[Full Log when I tried to drag a file name from my app to File Explorer using the <code>DoDragDrop</code> function.]</p>
  
  <pre><code>Mouse Down
  EnumFormatEtc
  EnumFormatEtc::Next(1)
  EnumFormatEtc::Next(1)
  EnumFormatEtc::Reset
  EnumFormatEtc::Next(1)
  EnumFormatEtc::Next(1)
  QueryGetData(cf = 15, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16230, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15835, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15834, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15833, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16215, ty = TYMED_ISTREAM, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  QueryGetData(cf = -16230, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15797, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  GetData(cf = -16206, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -15832, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  GetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  Returning null.
  SetData(cf = -16207, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  SetData(cf = -15864, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  SetData(cf = -15835, ty = TYMED_HGLOBAL, asp = DVASPECT_CONTENT)
  </code></pre>
  
  <p>[Relevant Code]</p>
  
  <pre><code>public void GetData(ref FORMATETC format, out STGMEDIUM medium)
  {
      Debug.WriteLine($"GetData(cf = {format.cfFormat}, ty = {format.tymed}, asp = {format.dwAspect})");
  
      if (format.cfFormat == CF_HDROP &amp;&amp;
          (format.tymed &amp; TYMED.TYMED_HGLOBAL) == TYMED.TYMED_HGLOBAL)
      {
          Debug.WriteLine("Returning file drop data");
          var mem = CreateDropFiles(new[] { file1, file2 
          });
  
          medium = new STGMEDIUM();
          medium.tymed = TYMED.TYMED_HGLOBAL;
          medium.unionmember = mem;
          medium.pUnkForRelease = IntPtr.Zero;
      }
      else
      {
          Debug.WriteLine("Returning null.");
          medium = new STGMEDIUM();
          medium.tymed = TYMED.TYMED_NULL;
          medium.unionmember = IntPtr.Zero;
          medium.pUnkForRelease = IntPtr.Zero;
      }
  }
  
  public int QueryGetData(ref FORMATETC format)
  {
      Debug.WriteLine($"QueryGetData(cf = {format.cfFormat}, ty = {format.tymed}, asp = {format.dwAspect})");
      if (format.cfFormat == CF_HDROP)
          return S_OK;
      else
          return DV_E_FORMATETC;
  }
  
  public void SetData(ref FORMATETC formatIn, ref STGMEDIUM medium, bool release)
  {
      Debug.WriteLine($"SetData(cf = {formatIn.cfFormat}, ty = {formatIn.tymed}, asp = {formatIn.dwAspect})");
  }
  </code></pre>
  
  <p>I used the <code>FORMATETC</code> in <code>System.Runtime.InteropServices.ComTypes</code>, which has <code>public short cfFormat</code>, but in Windows' API, it is defined as <code>CLIPFORMAT cfFormat</code>, which in turn <code>typedef WORD CLIPFORMAT</code>, which in turn <code>typedef unsigned short WORD;</code>. So, to me the type is mismatching (short and unsigned short). I am not sure if it matters or not.</p>