C# Wrapper Variant SafeArray

M

maddala

Hi,

I need help to wrap a C++ DLL using C# PInvoke. I have the
following function which needs a arapper function.

VARIANT _stdcall retVariantArray(void) {
COleSafeArray saRet;
DWORD numElements[] = {10, 10}; // 10x10

// Create the safe-array...
saRet.Create(VT_R8, 2, numElements);

// Initialize it with values...
long index[2];
for(index[0]=0; index[0]<10; index[0]++) {
for(index[1]=0; index[1]<10; index[1]++) {
double val = index[0] + index[1]*10;
saRet.PutElement(index, &val);
}
}

// Return the safe-array encapsulated in a
VARIANT...
return saRet.Detach();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top