title: GDI+ Image::SetPropertyItem not working as expected
body: <p>I am trying to use <code>SetPropertyItem</code> to set a Date Taken property to a file (<a href="https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-reading-and-writing-metadata-use" rel="nofollow noreferrer">click here for MSDN docs description</a>).</p>
  <p>I have tried assigning a newly initialized <code>FILETIME</code> to an input image with no success (or error messages). To ensure that it was not an issue with Date Taken, I also tried following <a href="https://docs.microsoft.com/en-us/windows/win32/api/gdiplusheaders/nf-gdiplusheaders-image-setpropertyitem" rel="nofollow noreferrer">this MSDN example</a> to no avail.</p>
  <p>Currently, I am attempting to extract a Date Taken property item from one input file (works fine) and attempting to set it to a different file. This approach does not work either, and the <code>Status</code> code returned is always 0 (Ok).</p>
  <p>The code I am using is below. I can only assume I am making a simple mistake or perhaps misunderstanding what <code>SetPropertyItem</code> is supposed to do. I thought that <code>SetPropertyItem</code> changed the metadata value such that it can be viewed through the Windows properties menu, like in <a href="https://i.stack.imgur.com/OTx3c.png" rel="nofollow noreferrer">this screenshot</a>.</p>
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;gdiplus.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  using namespace Gdiplus;
  
  #pragma comment(lib, &quot;gdiplus.lib&quot;)
  
  int main()
  {
      GdiplusStartupInput gdiplusStartupInput;
      ULONG_PTR gdiplusToken;
      GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);
  
      Image* image = new Image(L&quot;FakePhoto.jpg&quot;); // input image
  
      UINT totalBufferSize;
      UINT numProperties; // setup the buffer
      image-&gt;GetPropertySize(&amp;totalBufferSize, &amp;numProperties);
  
     // extract all metadata property items
     PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
     image-&gt;GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
  
     for (UINT j = 0; j &lt; numProperties; ++j)
     { // loop through each property
         if (pAllItems[j].id == PropertyTagExifDTOrig)
         { // if it's the Date Taken property
              PropertyItem* propItem = new PropertyItem;
              Image* newImage = new Image(L&quot;Test2.jpg&quot;);
              Status status; // second image
  
              propItem-&gt;id = PropertyTagExifDTOrig;
              propItem-&gt;length = pAllItems[j].length;
              propItem-&gt;type = PropertyTagTypeASCII;
              propItem-&gt;value = pAllItems[j].value;
              // create a new property item with the input photo Date Taken metadata
              status = newImage-&gt;SetPropertyItem(propItem);
  
              if (status == Ok)
                  std::cout &lt;&lt; &quot;No errors.&quot;;
          }
      }
  
      free(pAllItems);
      delete image;
      GdiplusShutdown(gdiplusToken);
  }
  </code></pre>
  <p>Any help is greatly appreciated. Also, I apologise about any obvious/potential errors. I am still learning the ropes as this is my first time using C++.</p>