createObject<T extends IInspectable> function
T
createObject<T extends IInspectable>()
Creates a WinRT object.
creator
must be the constructor of the class to be created (e.g.,
ICalendar.fromPtr
).
className
must be an activatable Windows Runtime class (e.g.,
Windows.Globalization.Calendar
).
iid
must be the IID of the object to be created (e.g., IID_ICalendar
).
final calendar = createObject(ICalendar.fromPtr,
'Windows.Globalization.Calendar', IID_ICalendar);
Implementation
T createObject<T extends IInspectable>(
T Function(Pointer<COMObject>) creator, String className, String iid) {
final inspectable = IInspectable(activateClass(className));
final object = inspectable.cast(creator, iid);
inspectable.free();
return object;
}