Пример #1
0
        private void InitFromRawPointer(IntPtr rawObjectPtr, bool addRef)
        {
            if (!UnmanagedMemoryHelper.ValidateComObject(rawObjectPtr))
            {
                throw new ArgumentException("Expected COM object, but validation failed.");
            }

            // We have to restrict interface requests to VBE hosted ITypeInfos due to a bug in their implementation.
            // See TypeInfoWrapper class XML doc for details.

            // VBE provides two implementations of ITypeInfo for each component.  Both versions have different quirks and limitations.
            // We use both versions to try to expose a more complete/accurate version of ITypeInfo.
            _typeInfoPointer =
                ComPointer <ITypeInfoInternal> .GetObjectViaAggregation(rawObjectPtr, addRef, queryType : false);

            _typeInfoAlternatePointer =
                ComPointer <ITypeInfoInternal> .GetObjectViaAggregation(rawObjectPtr, addRef, queryType : true);

            // safely test whether the provided ITypeInfo is hosted by the VBE, and thus exposes the VBE extensions
            HasVBEExtensions = ComHelper.DoesComObjPtrSupportInterface <IVBEComponent>(rawObjectPtr);

            InitCommon();
            DetectUserFormClass();
        }
 public TypeInfoVBEExtensions(ITypeInfoWrapper parent, IntPtr tiPtr)
 {
     _parent = parent;
     //_target_IVBEComponent = ComHelper.ComCastViaAggregation<IVBEComponent>(tiPtr);
     _vbeComponentPointer = ComPointer <IVBEComponent> .GetObjectViaAggregation(tiPtr, false, true);
 }