Implementing an IDispatch Interface for Each Service (Windows Embedded CE 6.0)
1/6/2010
For each UPnP service, a device application provides a COM object that implements the IDispatch interface.
For each <stateVariable> and <action> tag in the service description document, the COM object should include code that provides the required functionality.
For example, suppose the service description document contains the following XML:
...
<stateVariable>
<name>Power</name>
<dataType>boolean</dataType>
<defaultValue>0</defaultValue>
</stateVariable>
...
The IDL file that defines a local interface might include this code:
...
[id(DISPID_POWER), propget] HRESULT Power([out, retval] VARIANT_BOOL * pbPower);
[id(DISPID_POWER), propput] HRESULT Power([in] VARIANT_BOOL bPower);
...
The header file for the COM object might include this corresponding code:
...
STDMETHOD(get_Power)(/*[out, retval]*/ VARIANT_BOOL * pbPower);
STDMETHOD(put_Power)(/*[in]*/ VARIANT_BOOL bPower);
...
And the implementation file might include this code:
...
STDMETHODIMP CMyService::get_Power(/*[out, retval]*/ VARIANT_BOOL * pbPower)
{
// retrieve and return implementation
}
STDMETHODIMP CMyService::put_Power(/*[in]*/ VARIANT_BOOL bPower)
{
// set implementation
}
...
For assistance in generating the appropriate IDL file for a particular UPnP service description, developers can use the utl2idl tool. This tool translates a UTL service description into a COM IDL interface. This tool is not included with Platform Builder for Windows CE 5.0 but can be downloaded as part of the Microsoft Platform SDK. For more information, see this Microsoft Web site.