def CreateInstance(self, punkouter=None, interface=None, dynamic=False):
        if dynamic:
            if interface is not None:
                raise ValueError("interface and dynamic are mutually exclusive")
            realInterface = comtypes.automation.IDispatch
        elif interface is None:
            realInterface = comtypes.IUnknown
        else:
            realInterface = interface
        obj = ctypes.POINTER(realInterface)()
        self.__com_CreateInstance(punkouter, realInterface._iid_, ctypes.byref(obj))
        if dynamic:
            return comtypes.client.dynamic.Dispatch(obj)
        elif interface is None:
            # An interface was not specified, so return the best.
            return comtypes.client.GetBestInterface(obj)
        # An interface was specified and obj is already that interface.
        return obj

##class IExternalConnection(IUnknown):
##    _iid_ = GUID("{00000019-0000-0000-C000-000000000046}")
##    _methods_ = [
##        STDMETHOD(HRESULT, "AddConnection", [c_ulong, c_ulong]),
##        STDMETHOD(HRESULT, "ReleaseConnection", [c_ulong, c_ulong, c_ulong])]

# The following code is untested:
dataset/ETHPy150Open enthought/comtypes/comtypes/server/__init__.py/IClassFactory.CreateInstance/original