A couple of things, first the meat of your error
SysFreeString(pMess->Name.Detach());
Message::Name
is a raw BSTR pointer, which I assure you does not have a member function called Detach()
. The _bstr_t
class, however, does. Change your struct to:
typedef struct MESSAGE
{
int MessageType;
_bstr_t Name;
_bstr_t TimeStampIs;
} MESSAGE, *PMESSAGE;
Once done, you can remove the SysFreeString()
call entirely, since now both Name and TimeStampIs are smart pointers and will auto-free on object destruction.