Hi all: 
I have a question about the COM interface. Is the interface at the same fixed-order as: 
1. QueryInterface() 
2.AddRef() 
3. Release() 

(Means every interface in a COM object should have the QueryInterface() at the first, AddRef() second and the Release() at the third? Thanks

解决方案 »

  1.   

    I think so,if your original order is right.These three methods belongs to method and supported by every interface.And,in vtable they are always in a that order.
      

  2.   

    Is that order necessary? Can I change the order such as: 1.Release() 2. AddRef() 3. QueryInterface() ? Is the order specify by the COM specification? Thanks
      

  3.   

    I think cannot do so,because:  IUnknown::QueryInterface = *((LPBYTE)coclassptr->vptr)
      IUnknown::AddRef = *((LPBYTE)coclassptr->vptr)+4
      IUnknown::Release = *((LPBYTE)coclassptr->vptr)+8if you change the order,you will corrupt the internal scheme.