p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

comdeveloper thread: Accessing the members of a collection item

Message #1 by "Dimitris Stamatelos" <dstamat@s...> on Mon, 19 Feb 2001 19:05:54

I am building a COM application using as a guide the "Business Unit" 

example included in Ch 9 of Grimes's book : "Beginning ATL 3 COM 

Programming" .

I need to access the properties of the items of "DeveloperCollection" from 

within "CBusinessUnit". For example, I have added a method:

STDMETHODIMP CBusinessUnit::Access()


	CComBSTR Name;

	m_pManager->get_Name(&Name);   // works fine


	long Count;

	m_pDevelopers->get_Count(&Count); // returns Count as it should

        VARIANT pVal;

        m_pDevelopers->get_Item(Count, &pVal); //returns pVal


pVal is of type VT_DISPATCH. How can I access the Name and the other 

attributes of the items in the collection from pVal?  Where in pVal is the 

item stored?

I tried e.g  pval.pdispVal->get_Name(&Name) but it does not work.

Any ideas? I would appreciate any input and suggestions

Thank you in advance


  Return to Index