My understanding is that you should free it. The system couldn't know when you have finished with it, and BSTRs are simple beasties without destructors. Somewhere in MSDN there's a list of rules on this (but unfortunately I've forgotten where). There are also example in Don Box's "Essential Com" book.

Also, I think you could simplify the server side to:

CIDbSrv::GetName( BSTR * bname )
{
CString name;
HRESULT hr = S_FALSE;
if ( protecteddb.GetName( name ) )
{
*bname = name.AllocSysString();
hr = S_OK;
}
return hr;
}

Not that it makes that much difference...


Roger