BSTR tmp = ::SysAllocStringLen(NULL,destLen+srcLen);
dude you haven't added +2 bytes, it is crashing as that of mine, but when i added +2 it is running fine, so whenever i want allocate BSTR do i have 2 add + bytes.
A _bstr_t object encapsulates the BSTR data type. The class manages resource allocation and deallocation through function calls to SysAllocString and SysFreeString and other BSTR APIs when appropriate. The _bstr_t class uses reference counting to avoid excessive overhead.
Use the += operator of _bstr_t to append characters to the end.
if value is also declared as a type of _bstr_t then code can be re-written as,