title: ctypes and accessing com interface methods
body: <p>I am trying to load audio from Windows Media Foundation using python ctypes and coms, but having trouble getting it to work. </p>
  
  <p>The issue is I need an <code>IMFAttributes</code> interface object to use it's methods after creation, in this example <code>SetUINT32</code>. So to get the object of a pointer I am using <code>attrib_config.contents</code>, which does return an <code>IMAttributes</code> object. However, trying to access any methods to it causes a read access error.</p>
  
  <p>Here is the relevant code, without spamming the entire file. </p>
  
  <pre><code>class IMFAttributes(com.IUnknown):
      _methods_ = [
           .....
           ('SetUINT32',
           com.STDMETHOD(POINTER(GUID), c_uint32))
      ]
  
  MFCreateAttributes = mfplat.MFCreateAttributes
  MFCreateAttributes.restype = HRESULT
  MFCreateAttributes.argtypes = [POINTER(POINTER(IMFAttributes)), c_uint32]
  </code></pre>
  
  <p>Which should match what Microsoft recommends:</p>
  
  <pre><code>HRESULT MFCreateAttributes(
    IMFAttributes **ppMFAttributes,
    UINT32        cInitialSize
  )
  </code></pre>
  
  <p>Basically one double pointer, and int32.</p>
  
  <p>So I have initialized everything and create it as such:</p>
  
  <pre><code>MF_LOW_LATENCY = com.GUID(0x9c27891a, 0xed7a, 0x40e1, 0x88, 0xe8, 0xb2, 0x27, 0x27, 0xa0, 0x24, 0xee)
  
  MFStartup(MF_VERSION, 0)
  
  attrib_config = POINTER(IMFAttributes)()
  result = MFCreateAttributes(byref(attrib_config), 1)
  
  attrib_config.contents.SetUINT32(byref(MF_LOW_LATENCY), 1)
  </code></pre>
  
  <p>result returns as <code>S_OK</code> (0), but after I attempt to use <code>SetUINT32</code>, I instantly get <code>OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF</code></p>
  
  <p>I am new to ctypes, so any help would really be appreciated.</p>