title: EmfToWmfBits api always returns 0
body: <p>I want to use the EmfToWmfBits api. And first I will try to create a Metafile class then call this api. I think the problem is in the way I create the class. </p>
  
  <pre><code> Metafile myMetafile(szArglist[1]);
  </code></pre>
  
  <p>This way gives me the object myMetafile, but it contains nothing. I mean the nativeimage in this object is NULL, which is supposed to point to the metafile on my disk. So later when I call the EmfToWmfBits api, it gives me zero.</p>
  
  <p>I guess the problem might be the Metafile class should take a wchar string. And the filename on the disk is not wchar? I tried like this.</p>
  
  <pre><code> Metafile myMetafile(L"bird.emf");
  </code></pre>
  
  <p>And also this.</p>
  
  <pre><code> Metafile myMetafile(L"鸟.emf");
  </code></pre>
  
  <p>I am sure that the emf file is in the same directory with the exe. But all of them failed.</p>
  
  <p>This is the code I used.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;WINDOWS.H&gt;
  #include &lt;shellapi.h&gt;
  #include &lt;gdiplus.h&gt;
  
  #pragma comment(lib,"gdiplus.lib")
  #pragma comment(lib, "shell32.lib")
  
  using namespace Gdiplus;
  
  
  int main(int argc, char **argv)
  {
      UINT size1 = 0;
      int argcount;
      LPWSTR* szArglist;
  
      if (argc &lt; 2) {
          std::cout &lt;&lt; "Please input a file name" &lt;&lt; std::endl;
          return 0;
      }
  
  
      szArglist = CommandLineToArgvW(GetCommandLineW(), &amp;argcount);
      Metafile myMetafile(szArglist[1]);
      LocalFree(szArglist);
      HENHMETAFILE hEmf = myMetafile.GetHENHMETAFILE();
      size1 = Metafile::EmfToWmfBits(
          hEmf,
          0,
          NULL,
          MM_ANISOTROPIC,
          EmfToWmfBitsFlagsEmbedEmf);
      std::cout &lt;&lt; size1 &lt;&lt; std::endl;
  
  }
  </code></pre>
  
  <p>Normally, this EmfToWmfBits api should return the length of the converted file. The detail of this api is here.
  <a href="https://docs.microsoft.com/en-us/windows/win32/api/gdiplusheaders/nf-gdiplusheaders-metafile-emftowmfbits" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/windows/win32/api/gdiplusheaders/nf-gdiplusheaders-metafile-emftowmfbits</a>
  I would appreciate if anyone can help me here.</p>