ConvertBSTRToString

  // TODO: code your application's behavior here.
  BSTR bstrText = ::SysAllocString(L"aaaaaaaaa");                                                  //::SysAllocString(L"Test");
  wprintf(L"BSTR text: %s/n", bstrText);
  char* lpszText2 = ::_com_util::ConvertBSTRToString(bstrText);             //_com_util::ConvertBSTRToString(bstrText);
  printf("char * text: %s/n", lpszText2);
  SysFreeString(bstrText);
  delete[] lpszText2;


  char* lpszText = "Test";
  printf("char * text: %s/n", lpszText);
  BSTR bstrText2 = _com_util::ConvertStringToBSTR(lpszText);
  wprintf(L"BSTR text: %s/n", bstrText2);
  SysFreeString(bstrText);

你可能感兴趣的:(application,delete,behavior)