如何将字符串数组转换为SAFEARRAY或VARIANT或COleVariant?

时间:2015-06-11 01:04:03

标签: c++ com ole variant safearray

我正在处理OLE(COM),所以我想将字符串数组转换为SAFEARRAY或CComSafeArray或COleSafeArray或VARIANT或COleVariant。

  1. CString [100] - > SAFEARRAY
  2. CString [100] - > CComSafeArray
  3. CString [100] - > COleSafeArray
  4. CString [100] - > VARIANT
  5. CString [100] - >的COleVariant
  6. 将转换后的字符串数组转换为SAFEARRAY或CComSafeArray或COleSafeArray或VARIANT或COleVariant发出OLEMethod来执行COM。

    请帮帮我

1 个答案:

答案 0 :(得分:2)

CString strings[100];

CComSafeArray<BSTR> myArray(100);
for (int i = 0; i < 100; ++i) {
  myArray.SetAt(i, strings[i].AllocSysString(), /*copy=*/ false);
}