title: How to acquire instance of IWICImagingFactory in winapi-rs
body: <p>So in <a href="https://stackoverflow.com/questions/68795998/how-to-pass-a-reference-to-a-buffer-as-a-pointer-of-type-sometype1-in-rust">my previous question</a> I was advised to convert byte buffers to <code>IStream</code> via <code>SHCreateMemStream</code> and use <code>IWICImagingFactory::CreateDecoderFromStream</code>. The first part already caused some complications as winapi-rs did contain an <a href="https://docs.rs/winapi/0.3.9/winapi/um/objidlbase/struct.IStream.html" rel="nofollow noreferrer">implementation</a> for the <code>IStream</code> but not the function itself - thankfully <code>winapi-rs</code> contained everything i needed to link it as follows:</p>
  <pre class="lang-rs prettyprint-override"><code>pub type HIStream = *const IStream;
  
  extern &quot;system&quot; {
      pub fn SHCreateMemStream(pbInit: *const BYTE, cbInit: UINT) -&gt; HIStream;
  }
  </code></pre>
  <p>.
  Now I face a similar issue with the <code>IWICImagingFactory</code> class which I need to call the <code>CreateDecoderFromStream</code> method. However it according to the <a href="https://docs.rs/winapi/0.3.9/winapi/um/wincodec/struct.IWICImagingFactory.html" rel="nofollow noreferrer">documentation</a> it takes a <code>&amp;self</code> parameter and similarly to the <code>IStream</code> is a trait from my understanding. How can  I obtain new instance of <code>IWICImagingFactory</code> without implementing it from scratch. I saw some talk about a function called <code>CoCreateInstance</code> and some com API specifics but that wasn't very clear as I have a very poor understanding of com API as for now.</p>