How to convert string array to SAFEARRAY or VARIANT or COleVariant?

2.5k views Asked by At

i'm working about OLE(COM) ,so that i want to convert string array to SAFEARRAY or CComSafeArray or COleSafeArray or VARIANT or COleVariant.

  1. CString[100] -> SAFEARRAY
  2. CString[100] -> CComSafeArray
  3. CString[100] -> COleSafeArray
  4. CString[100] -> VARIANT
  5. CString[100] -> COleVariant

converted string array to SAFEARRAY or CComSafeArray or COleSafeArray or VARIANT or COleVariant is sended OLEMethod to do COM.

please help me

1

There are 1 answers

0
Igor Tandetnik On BEST ANSWER
CString strings[100];

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