示例#1
0
 public static extern uint CoCreateInstanceEx(
     [In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid,
     [In] IntPtr punkOuter,
     [In] RegistrationClassContext dwClsCtx,
     [In] ref IntPtr pServerInfo,
     [In] uint dwCount,
     //[In, Out] IntPtr pResults
     [In, Out] IntPtr pResults
     );
示例#2
0
 public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (type as RuntimeType == null)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
     }
     if (!this.TypeRequiresRegistration(type))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"), "type");
     }
     return(RegistrationServices.RegisterTypeForComClientsExNative(type, classContext, flags));
 }
示例#3
0
		public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
		{
			throw new NotImplementedException ();
		}
示例#4
0
        public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
        {
#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
            if (type == null)
                throw new ArgumentNullException("type");
            Contract.EndContractBlock();
            if ((type as RuntimeType) == null)
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),"type");
            if (!TypeRequiresRegistration(type))
                throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),"type");
            
            // Call the native method to do CoRegisterClassObject
            return RegisterTypeForComClientsExNative(type, classContext, flags);
#else // FEATURE_COMINTEROP_MANAGED_ACTIVATION
            throw new NotImplementedException("CoreCLR_REMOVED -- managed activation removed");
#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION
        }
示例#5
0
 private static extern int RegisterTypeForComClientsExNative(Type t, RegistrationClassContext clsContext, RegistrationConnectionType flags);
 public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
     throw new NotImplementedException();
 }
 public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
 }
示例#8
0
 private static extern int RegisterTypeForComClientsExNative(Type t, RegistrationClassContext clsContext, RegistrationConnectionType flags);
示例#9
0
 public static extern HResult CoRegisterClassObject([MarshalAs(UnmanagedType.LPStruct)] Guid rclsid,
     [MarshalAs(UnmanagedType.Interface)]IClassFactory pUnkn,
     RegistrationClassContext dwClsContext,
     RegistrationConnectionType flags,
     out IntPtr lpdwRegister);
示例#10
0
 public virtual new int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
     return(default(int));
 }
示例#11
0
        public static uint CoCreateInstanceEx_Hook(
            Guid rclsid,
            IntPtr punkOuter,
            RegistrationClassContext dwClsCtx,
            ref IntPtr pServerInfo,
            uint dwCount,
            IntPtr pResults
            )
        {
            uint result = CoCreateInstanceEx(
                rclsid,
                punkOuter,
                dwClsCtx,
                ref pServerInfo,
                dwCount,
                pResults
                );

            if (dwCount > 0)
            {
                //To access the MULTI_QI array from inside the EasyHook delegate,
                //we have to manually marshal it because it was causing crashes.
                MULTI_QI[] pResultsObj = new MULTI_QI[dwCount];

                for (int i = 0; i < dwCount; i++)
                {
                    MULTI_QI qi       = new MULTI_QI();
                    IntPtr   ptrToIID = Marshal.ReadIntPtr(pResults);
                    qi.IID   = (Guid)Marshal.PtrToStructure(ptrToIID, typeof(Guid));
                    pResults = IntPtr.Add(pResults, IntPtr.Size);
                    qi.pItf  = Marshal.ReadIntPtr(pResults); //A pointer to the interface requested in pIID. This member must be NULL on input.

                    pResults = IntPtr.Add(pResults, IntPtr.Size);

                    switch (IntPtr.Size)
                    {
                    case 8:     //64-bit:
                        qi.hr    = (uint)Marshal.ReadInt64(pResults);
                        pResults = IntPtr.Add(pResults, sizeof(UInt64));
                        break;

                    case 4:     //32-bit:
                        qi.hr    = (uint)Marshal.ReadInt32(pResults);
                        pResults = IntPtr.Add(pResults, sizeof(UInt32));
                        break;

                    default:
                        break;     //unknown platform
                    }


                    //68cce6c0... is Access._Application interface
                    if (qi.hr == S_OK && qi.IID == Guid.Parse("68cce6c0-6129-101b-af4e-00aa003f0f07"))
                    {
                        Microsoft.Office.Interop.Access.Application app;

                        app = Marshal.GetObjectForIUnknown(qi.pItf) as Microsoft.Office.Interop.Access.Application;

                        if (app != null)
                        {
                            uint ProcID = 0;
                            GetWindowThreadProcessId(app.hWndAccessApp(), out ProcID);

                            try
                            {
                                lock (This.AccessInstances)
                                {
                                    if (ProcID != 0)
                                    {
                                        This.AccessInstances.Enqueue(ProcID);
                                    }
                                }
                            }
                            catch { }
                        }
                    }

                    pResultsObj[i] = qi;
                }
            }

            return(result);
        }
 public virtual new int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
   return default(int);
 }
 public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (!(type is RuntimeType))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
     }
     if (!this.TypeRequiresRegistration(type))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"), "type");
     }
     return RegisterTypeForComClientsExNative(type, classContext, flags);
 }
示例#14
0
 public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
 }