How to convert _bstr_t to CString

前端 未结 5 476
春和景丽
春和景丽 2021-01-17 10:41

I have a _bstr_t variable bstrErr and I am having a CString variable csError. How do I set the value which come in

5条回答
  •  悲哀的现实
    2021-01-17 11:03

    BSTR myBSTRVal;
    CString BSTRasCString("")
    char  szValue[MAX_PATH] = "";
    
    // This will map the BSTR to a new character string (szValue)
    WideCharToMultiByte(CP_ACP, 0, myBSTRVal, -1, szValue, sizeof(szValue), NULL, 
    NULL);
    BSTRasCString.Format("%s", szValue);                
    BSTRasCString.TrimLeft();
    BSTRasCString.TrimRight();
    

提交回复
热议问题