SafeArrayPutElement ??

S

Scott Metzger

Hi,

I am trying to create a safe array of shorts and I am having trouble
with SafeArrayPutElement. How is this used?

Here is my code...
SAFEARRAY* filter;
SAFEARRAYBOUND bound[1];
bound[0].lLbound = 0;
bound[0].cElements = 7;
filter = SafeArrayCreate(VT_I2, 1, bound);
long index[7];
/*
index[0] = 0;
index[1] = 1;
index[2] = 2;
index[3] = 3;
index[4] = 4;
index[5] = 5;
index[6] = 6;
*/
SafeArrayPutElement(filter, index, (void*)visSectionUser);
SafeArrayPutElement(filter, index, (void*)visSectionUser);
SafeArrayPutElement(filter, index, (void*)visRowUser);
SafeArrayPutElement(filter, index, (void*)visUserValue);
SafeArrayPutElement(filter, index, (void*)visSectionUser);
SafeArrayPutElement(filter, index, (void*)visRowUser);
SafeArrayPutElement(filter, index, (void*)visUserValue);
SafeArrayPutElement(filter, index, (void*)1);

When I initilize the index variable I get an unhandled exception when I
make my call to SafeArrayPutElement. But when I don't initilize it and
I go to use my SAFEARRAY things don't work correctly. Am I using
SafeArrayPutElement correctly?

Thanks,
Scott Metzger
 

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