oledb - Is is allowed, by COM rules, to do reference count per Interface instance? -


I am having an accident with Excel, while this is an OLE DB provider that I am writing, and the reason seems, After digging through some disassembly, due to trying to call a method called IDBIfon, the provider was already destroyed (as if its reference number was below 0.)

Now, in this provider, every call to QueryInterface on any of my interfaces Always returns a new (C ++) object (which represents all IUnknown methods for a normal object that excludes the whole COM object except IUnknown, for example, from my provider 'Live' given to IUnknown A (and believe QueryInterface is successful),

For example, / P>

  ISIM Interface * B; ISOM Interface * C; A-> Query Interface (IID_ISome Interface, (Zero **) and B); // B.Refactant = 1. A-> Query In Rfes (IID_ISome interface, (void **) & amp; C); // C Rifount = 1, B Rifcunt unchanged. C & gt; Release (); // C refund = 0, C is lost, B is reflex unchanged. C & gt; SomeMethod (); // C will be an accident, even if the CD is destroyed, even though there is an outstanding 'live' ISOM interface example on the same object (ie B). According to  

, it is valid, if weird, the implementation looks like.

Am I really sharing the COM rules here?

the way AddRef and release Treatment is considered as reference reference on each indicator every time you make a copy of the indicator, you can add AddRef ; And every time you stop using the pointer, you can delete the object properly when release , when no interface pointsers have left that point.

(In practice it is usually optimized to a certain extent, for example in a situation where you pass the interface pointer on a function is completely under your control, for the function logic AddRef and the release function will not be a problem for you.

To answer your question: Indicator 0 after the refraction of C is gone, this can be done by doing C-> It is illegal.Pointer C has expired, even if the indicated object still exists.

This difference does not make sense how you implemented the interface Whether it is supported by the C ++ object, or whatever the interface is completely opaque, which is one of the basic concepts of COM. The rule says that the customer will call any call through that indicator does not make, B 0 .


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -