title: How to create DirectX12 COM objects in C++ and use it in C# to initialize objects in Silk.NET
body: <p>I use a nuget package called Silk.NET to use DirectX12 in C#. For example, I can create an IDXGIFactory5 with the following code:</p>
  <pre><code>var dxgi = DXGI.GetApi();
  var d3d12 = D3D12.GetApi();
  var factoryFlags = 0u;
  var factoryiid = IDXGIFactory5.Guid;
  IDXGIFactory5* factory = null;
  dxgi.CreateDXGIFactory2(factoryFlags, ref factoryiid, (void**)&amp;factory);
  </code></pre>
  <p>But for some unavoidable reasons, I have to create the IDXGIFactory5 COM interface in C++:</p>
  <pre><code>ComPtr&lt;IDXGIFactory5&gt; factory;
  CreateDXGIFactory2(0, IID_PPV_ARGS(&amp;factory));
  </code></pre>
  <p>How can I convert the COM interface created in C++ to the type in Silk.NET?</p>
  <p>(Because I am not good at English, I am using Google Translate to ask questions, please forgive me)</p>