Listing the Adapters

Now the name of each server and the description of each adapter must be retrieved.

This code performs the following steps to loop through all the servers in the array and then find all the adapters on each server. The descriptions of the adapters are stored, as shown. The description of each adapter stored in this list will be displayed in the menu.

  1. Find the number of servers in the array. Here the number of servers is retrieved by using the Count property of the FPCServers administration COM object.
    	int Servnum = spiServers->Count;
    	int index,index2,LineNumber=0;
    	VARIANT ItemNum;
       
    
  2. Loop through all servers in the array, and find all adapters on each server. Here is where the code uses the FPCServer and FPCAdapters administration COM objects to retrieve information about the adapters.
    	/* Loop on all the servers */
    	for (index=1;index<=Servnum;index++)
    	{
    		ItemNum.vt = VT_I4;
    		ItemNum.lVal =  index;
    		FPCLib::IFPCServerPtr spiServer(spiServers->Item(ItemNum));
    		_bstr_t name = spiServer->Name;
    		FPCLib::IFPCAdaptersPtr spiAdapterList(spiServer->Adapters);
    	
    		int AdapNum = spiAdapterList->Count;
     
    		/* Make a node for this server */
    		ServItem = m_ListTree.InsertItem( name, 0, 0,RootItem);
     
    		/* Loop on all the adapters */
    		for (index2=1;index2<=AdapNum;index2++)
    		{
    			FPCLib::IFPCAdapterPtr spiAdapter(spiAdapterList->Item(index2));
    			_bstr_t Desc = spiAdapter->Description;
     
    			/* Make a line for every adapter */
    			m_ListTree.InsertItem( Desc, 0, 0,ServItem);
    			m_ListCtl.InsertItem( (LineNumber), _T("")); 
    			m_ListCtl.SetItemText((LineNumber),0, name );
    			m_ListCtl.SetItemText((LineNumber),1, Desc);
    			LineNumber++;
     
    	}
     
    }
    

Send comments about this topic to Microsoft

Build date: 11/30/2009

© 2008 Microsoft Corporation. All rights reserved.