Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have Created ATL Project in VS2010.
I am having my ATL Control.
I have added Method given below.

Code in IDL File:
[id(2)] HRESULT GiveOutput([out] VARIANT* theArray);

Code in Header File:
STDMETHOD(GiveOutput)(VARIANT* theArray);

Code in CPP File:
STDMETHODIMP CATLSampleCtrl::GiveOutput(VARIANT* theArray)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
VariantInit(&(*theArray));
SAFEARRAYBOUND aDim[2];
aDim[0].lLbound = 0;
aDim[0].cElements = 5;
aDim[1].lLbound = 0;
aDim[1].cElements = 2;

(*theArray).vt = VT_ARRAY | VT_I4;
(*theArray).parray = SafeArrayCreate(VT_I4, 2, aDim);

for(int nCount = 0; nCount < 5; nCount++)
{
(int*)((*theArray).parray->pvData[nCount]) = new int[2];
for(int nCount1 = 0; nCount1 < 2; nCount1++)
{
(int*)(*theArray).parray->pvData[nCount][nCount1] = (LPVOID)(nCount + nCount1);
}
}
return S_OK;
}


I want to fetch output array in VB Sample having 5 values.
It is not working, nothing is updated.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900