refCount function
Returns the current reference count of the COM object.
Implementation
int refCount(IUnknown unk) {
// Call addRef() and release(), which are inherited from IUnknown. Both return
// the refcount after the operation, so by adding a reference and immediately
// removing it, we can get the original refcount.
unk.addRef();
final refCount = unk.release();
return refCount;
}