03-23-2013, 06:50 PM
Macro Macro2009
extern "C" __declspec(dllexport)
bool myfunc(SAFEARRAY* a) //ARRAY(BSTR)
{
if(!a || !(a->fFeatures&FADF_BSTR) || a->cDims!=1 || a->rgsabound[0].lLbound || a->cLocks) return 0;
BSTR* p=(BSTR*)a->pvData, *pe=p+a->rgsabound[0].cElements;
for(; p<pe; p++) *p=SysAllocString(L"test");
return true;
}
It is possible to make calling the function simpler. For example, set a callback function that allocates array and converts BSTR to str. Then caller will not have to do it.
dll "..." !myfunc ARRAY(BSTR)a
ARRAY(BSTR) b.create(5)
out myfunc(b)
ARRAY(str) a.create(b.len); for(_i 0 a.len) a[_i]=b[_i] ;;tip: create function for this
out a
extern "C" __declspec(dllexport)
bool myfunc(SAFEARRAY* a) //ARRAY(BSTR)
{
if(!a || !(a->fFeatures&FADF_BSTR) || a->cDims!=1 || a->rgsabound[0].lLbound || a->cLocks) return 0;
BSTR* p=(BSTR*)a->pvData, *pe=p+a->rgsabound[0].cElements;
for(; p<pe; p++) *p=SysAllocString(L"test");
return true;
}
It is possible to make calling the function simpler. For example, set a callback function that allocates array and converts BSTR to str. Then caller will not have to do it.