There is a class A that derives from _bstr_t. It needs to have a method that takes a wchar_t* and copies the bstr into it. Is this the safest way to do it if wcsncpy_s understands bstrs?
class A: public _bstr_t
{
----
----
void CopyTo(wchar_t* buf, size_t destinationsize)
{
wcsncpy_s(buf, destinationsize, *this, length());
}
};
I think you want this:
If you don’t use _TRUNCATE, then the invalid parameter handler will be invoked when the buffer is too small to contain the entire string (plus null):
http://msdn.microsoft.com/en-us/library/ksazx244%28v=vs.80%29.aspx