Example #1
0
 /// <summary>
 /// Creates a single uninitialized object of the class associated with a specified <typeparamref name="TActiveX">type</typeparamref>.
 /// </summary>
 /// <typeparam name="TClass">Class to create instance of.</typeparam>
 /// <typeparam name="TInterface">Interface to cast to.</typeparam>
 /// <param name="punkOuter"><see langword="null"/> if the object is not being created as part of an aggregate;
 /// otherwise, a reference to the aggregate object's IUnknown interface (the controlling IUnknown).</param>
 /// <param name="context">Context in which the code that manages the newly created object will run. The values are taken from the enumeration <see cref="TActiveX:NativeMethods.tagCLSCTX"/>.</param>
 /// <param name="iid">Reference to the identifier of the interface to be used to communicate with the object.</param>
 /// <returns>
 /// The instance requested in <paramref name="riid"/>.
 /// </returns>
 /// <remarks>
 /// Wrapper to <see cref="M:CoCreateInstance"/>.
 /// </remarks>
 /// <typeparam name="TActiveX">The type of the instance to be created.</typeparam>
 public static TInterface CoCreateInstance <TClass, TInterface>(object punkOuter, NativeMethods.tagCLSCTX context, Guid iid)
 {
     return((TInterface)CoCreateInstance(typeof(TClass).GUID, punkOuter, context, iid));
 }
Example #2
0
 public static extern object CoCreateInstance(
     [In, MarshalAs(UnmanagedType.LPStruct)] Guid clsid,
     [In, MarshalAs(UnmanagedType.Interface)] object punkOuter,
     [In, MarshalAs(UnmanagedType.I4)] NativeMethods.tagCLSCTX context,
     [In, MarshalAs(UnmanagedType.LPStruct)] Guid iid);