Write Default Data
When an Apply event occurs, an extension to the Applications snap-in can write its default name to the XML document, IXMLDOMDocument. The value set in this name attribute becomes the name assigned to the item when the property sheet closes and is typically the name of the application that this extension represents. An extension to the Applications snap-in should also verify that a Properties element is created, under which the properties will be stored.
Code Sample
The code to write default data is available in the AppExt.cpp for the full code example. The following code example shows how to write default data.
IXMLDOMNode* pElmApp = NULL;
// Get the "Application" element:
HRESULT hr = pThis->m_pXmlDom->selectSingleNode( L"/Application",
&pElmApp );
if ( hr == S_OK )
{
BSTR bstrName;
hr = GetAttribute( pElmApp, _T( "name" ), bstrName );
if ( hr == S_FALSE )
{
// "name" attribute not found, create:
SetAttribute( pThis->m_pXmlDom, pElmApp, _T( "name" ),
_T( "<<APPLICATION_NAME>>" ) );
}
IXMLDOMNode* pElmProps = NULL;
// Get the "Properties" element:
hr = pThis->m_pXmlDom->selectSingleNode(
L"/Application/Properties", &pElmProps );
if ( hr == S_FALSE )
{
// "Properties" element not found, create:
hr = AddElement( pThis->m_pXmlDom, pElmApp, _T( "Properties" ),
&pElmProps );
}