Reputation:
I am newbie in com known little bit about MFC where we can use CStringArray for collection of string. I in following case of com component i am confused how to use string in com. Following is case, I am developing com component as well as also using it,In my com component following is requirement of function, Reading two dimensional array from xml file and dumping it into one common array like,
_bstr_t bstrMember1Name,bstrMember2Name;
IEachData portsDataNode;
while(portsDataNode = CollectionOfData->NextData())
{
if (!GetStringAttribute(portsDataNode, _T("Member1"), bstrMember1Name))
{
hr = E_FAIL;
}
if (!GetStringAttribute(portsDataNode, _T("Member2"), bstrMember2Name))
{
hr = E_FAIL;
}
}
This is body of function as i get Member1 and Member2 as return type from One com companant call but i need collection of each and value.So what is the parameter of function?How i collect Member1 and Member2 into single variable??
Upvotes: 1
Views: 88
Reputation: 15385
Sorry. I didn't understand your question in that way. If you want to return a collection (say Array) of data, you Need a SAFEARRAY. So use SafeArrayCreate. If i tis not COM only and you Need Automation you have to use an VARIANT Safe Array. SAFEARRAY can be passed cross COM boundaries. SAFEARRAYs of BSTRs are possible. Also Multi dimensional Arrays
Upvotes: 1