Accessing Collection Objects Managed by the Control from C++ Programs


The NetShow Unicast Manager control, like all ActiveX controls, follows OLE Automation guidelines. Its events, methods, and properties are exposed through the IDispatch interface. Each of the collection objects managed by the control is itself an OLE object with its own IDispatch interface implementing its own events, methods, and properties.

GUIDs

Following is a list of the globally unique identifiers (GUIDs) that identify the object classes and IDispatch interfaces of the collection objects managed by the Unicast Manager control:

Definitions

The following code defines the interfaces for these collection objects:

interface INsoClients : public IDispatch
{
public:
    virtual HRESULT STDMETHODCALLTYPE get_Item(long nIndex,IDispatch __RPC_FAR *__RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE get_Count(long __RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE get__NewEnum(IUnknown __RPC_FAR *__RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE put__Locale(long localeId) = 0;
};

interface INsoClient : public IDispatch
{
public:
    virtual HRESULT STDMETHODCALLTYPE get_ClientID(DWORD __RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE get_PortID(DWORD __RPC_FAR *retval) = 0;    
    virtual HRESULT STDMETHODCALLTYPE get_IPAddress(BSTR __RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE Disconnect( void) = 0;
    virtual HRESULT STDMETHODCALLTYPE put__Locale(long localeId) = 0;   
};

interface INsoVirtualRoots : public IDispatch
{
public:
    virtual HRESULT STDMETHODCALLTYPE get_Item(long nIndex,IDispatch __RPC_FAR *__RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE get_Count(long __RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE get__NewEnum(IUnknown __RPC_FAR *__RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE put__Locale(long localeId) = 0;    
    virtual HRESULT STDMETHODCALLTYPE Add(BSTR pszAliasName,BSTR pszVirtualDirectory) = 0;
    virtual HRESULT STDMETHODCALLTYPE Remove(BSTR pszAliasName) = 0;  
};

interface INsoVirtualRoot : public IDispatch
{
public:
    virtual HRESULT STDMETHODCALLTYPE get_DirectoryPath(BSTR __RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE get_AliasName(BSTR __RPC_FAR *retval) = 0;
    virtual HRESULT STDMETHODCALLTYPE put__Locale(long localeId) = 0;
    virtual HRESULT STDMETHODCALLTYPE SetAsHome( void) = 0;   
};

Implementation

The following routine shows how to implement the collections. It demonstrates how an application can retrieve pointers to the objects. This routine assumes that a successful connection has been made to the unicast server.


{
	INsoClients* pClients;
	INsoClient* pClient;
	long NumClients;
	DWORD ClientID, PortID;
	BSTR strIPAddress;
 	
	pClients = (INsoClients*)m_nsunimgr.GetClients();
	if(pClients)
	{
		pClients->get_Count(&NumClients);
		for (int cc=0;cc<NumClients;cc++)
		{
			pClients->get_Item(cc, (LPDISPATCH*)&pClient);
			pClient->get_ClientID(&ClientID);
			pClient->get_PortID(&PortID);
			pClient->get_IPAddress(&strIPAddress);
			SysFreeString(strIPAddress);
			pClient->Release();
		}
		pClients->Release();
	}

	INsoVirtualRoots* pVRoots;
	INsoVirtualRoot* pVRoot;
	long NumVRoots;
	BSTR strDirectory, strAliasName;

	pVRoots = (INsoVirtualRoots*)m_nsunimgr.GetVirtualRoots();
	if(pVRoots)
	{
		pVRoots->get_Count(&NumVRoots);
		for (int cc=0;cc<NumVRoots;cc++)
		{
			pVRoots->get_Item(cc, (LPDISPATCH*)&pVRoot);
			pVRoot->get_DirectoryPath(&strDirectory);
			pVRoot->get_AliasName(&strAliasName);
			SysFreeString(strDirectory);
			SysFreeString(strAliasName);
			pVRoot->Release();
		}
		pVRoots->Release();
	}
}

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.