API See also ITcSmTreeItem::ProduceXML [ } 60] 6.2.5 ITcSmTreeItem::CreateChildITcSmTreeItem Creates a child itemon a parent node. The childis being specified by it's subtype [ } 41] . HRESULT CreateChild(BSTRbstrName,long nSubType, BSTRbstrBefore, VARIANT vInfo,ITcSmTreeItem**pipItem ); The following example demonstrates this behavior in better detail. In this example, an EK1100 coupler is being added to an EtherCAT Master device (Device 1) in TwinCAT XAE. In Automation Interface, this could be done with the CreateChild() method. The parent node (Device 1 EtherCAT) has the item type '2' (TREEITEMTYPE_DEVICE).
The sub type specifies the child item and therefore the EK1100, which is sub type '9099' (BOXTYPE_EXXXXX). Parameters Return Values Automation Interface 62 Version: 1.2 bstrName [in] Item name of the new child item. nSubType [in]S [} 41]ub type [} 41] of the new child item. The usable sub type depends on theitem type [} 39](the category)of theparenttree item. For example, a PLC Functionblock may only be added to the item type PLCFOLDER and not to a DEVICE. bstrBefore [in, defaultvalue("")] If set, the parameter contains the name of another child item before that the new item should be inserted.
vInfo [in, optional] An optional parameter with additional creation information, whichdepends on the sub type [} 41].The different dependencies are listed in the table below. pipItem [out, retval] Points to the location of a ITcSmTreeItem [} 37] interface pointer that receives the result. S OK _ function returns successfully. E POINTER _ the location of the returning pointer is invalid TSM E INVALIDITEMSUBTYPE _ _ (0x98510003) the given sub type is invalid. TSM E ITEMNOTFOUND (0x98510001) _ _ The item bstrBefore was not found.