I have create a .Net component which exposes an interface with two methods. The first method takes an array of structs as a parameter the other method returns an array of (the same tyoes of) structs.
When I get the array structures from my second method in unmanaged c++, I cannot regonize any of the parameters in the structures. But if I pass the same pointer to the first method in my interface and look at the values in .net then thay are all intact.
Can anyone tell my how to read these values in unmanaged c++?
Code and more explanations:
The regasm of the .net code gives an interface in the .tlh file like this:
HRESULT Input( SAFEARRAY * calibRecords );
SAFEARRAY * Output( );
and my stryct:
MyRecord { double r; };
In c++ i get the dispatch interface to the library and then do a queryInterface for my interface like this:
ITool *p;
HRESULT hr = pDisp->QueryInterface(&p);
SAFEARRAY *psa = p->Output();
I know there are 2 elements in the array, so I do the following:
MyRecord *cc=new MyRecord[2];
hr = SafeArrayAccessData(psa, reinterpret_cast<void**>(&cc));
But ther values in cc is NOT the correct ones.
If I then do a hr = p->Input(psa); and looks at the values in the .net application then all looks fine.
Please help me...