No specific API; it's released when the reference counter of the object you created hits 0.
VB handles this automatically for you. Set object = Nothing will do it immediately. Once in a great while, you have reason to override VB's automatic management; you can cast it to an unrestricted IUnknown, call AddRef, then it has a reference count different from what VB is aware of, so won't be released until you call Release an equal number of times as AddRef.
All COM objects (what you're creating with CoCreateInstance) must implement IUnknown, and the standard implementation for Release looks like this:
Code:
ULONG CMyObj::Release()
{
if (--m_dwRef == 0)
{
delete this;
return 0;
}
return m_dwRef;
}
That's where it's freed when the counter hits 0.
...if you *really* wanted an API for it; there's a helper function; IUnknown_AtomicRelease in shlwapi.dll. You really shouldn't call that from VB though. Probably wind up crashing.