FW_ObjMgr_CreateAndInitInstance

This function generates an instance of the class specified by means of Class-ID and at the same time returns an interface pointer to this object. In addition the object name and state into which the object is to be put, as well as optionally also initialization parameters can be specified.
Return value
FW_ObjMgr_CreateAndInitInstance : HRESULT;
Name | Type | Description |
---|---|---|
FW_ObjMgr_CreateAndInitInstance | HRESULT | Returns S_OK if the function call was successful. |
Inputs
VAR_INPUT
clsId : CLSID;
iid : IID;
pipUnk : POINTER TO ITcUnknown;
objId : UDINT;
parentId : UDINT;
name : REFERENCE TO STRING;
state : UDINT;
pInitData : POINTER TO TComInitDataHdr;
END_VAR
Name | Type | Description |
---|---|---|
clsId | CLSID | Specifies the class from which an object should be created. |
iid | IID | Specifies the interface ID to which an interface pointer should be referenced. |
pipUnk | POINTER TO ITcUnknown | Returns the interface pointer to the created object. |
objId | UDINT | Specifies the object ID for the newly created object. If the global constant OTCID_CreateNewId is entered here a new object ID is generated internally. |
parentId | UDINT | Object ID of the parent object (optional) |
name | REFERENCE TO STRING | Specifies the object name which should be assigned for the newly created object. |
State | UDINT | Specifies the state into which the newly created object should be put. Typically Operational (TCOM_STATE.TCOM_STATE_OP) is specified. |
pInitData | POINTER TO TComInitDataHdr | Pointer to initialization parameter (optional) |
![]() | Necessary deletion of the object A generated object must be explicitly deleted again. There is no Garbage-Collector as in .Net. It is recommended to use FW_ObjMgr_DeleteInstance, in order to delete the generated instance at the latest in the destructor of the object which created the instance. |
Requirements
TwinCAT Version | Hardware | Libraries to be integrated |
---|---|---|
TwinCAT 3.1, Build 4020 | x86, x64, ARM | Tc3_Module |