/// <summary>Initializes a new instance of the <see cref="ComClassFactory"/> class.</summary> /// <param name="punkObject">The COM object that is to be registered as a class object and queried for interfaces.</param> /// <param name="classContext">The context within which the COM object is to be run.</param> /// <param name="classUse">Indicates how connections are made to the class object.</param> public ComClassFactory(IComObject punkObject, CLSCTX classContext, REGCLS classUse) { comObj = punkObject ?? throw new ArgumentNullException(nameof(punkObject)); CoRegisterClassObject(comObj.GetType().CLSID(), this, classContext, classUse, out registrationId).ThrowIfFailed(); }
/// <summary>Initializes a new instance of the <see cref="ShellDropTarget"/> class.</summary> /// <param name="classContext">The context within which the COM object is to be run.</param> /// <param name="classUse">Indicates how connections are made to the class object.</param> protected ShellDropTarget(CLSCTX classContext, REGCLS classUse) : base(classContext, classUse) { }
public void Register(CLSCTX classContent = CLSCTX.CLSCTX_LOCAL_SERVER, REGCLS classUse = REGCLS.REGCLS_SINGLEUSE) => CoRegisterClassObject(typeof(TObjectToFactory).GUID, this, classContent, classUse, out _dwRegisterClass);
public static extern int CoRegisterClassObject( ref Guid rclsid, [MarshalAs(UnmanagedType.Interface)] IClassFactory pUnk, CLSCTX dwClsContext, REGCLS flags, out uint lpdwRegister);
/// <summary>Initializes a new instance of the <see cref="ShellCommand"/> class.</summary> /// <param name="classContext">The context within which the COM object is to be run.</param> /// <param name="classUse">Indicates how connections are made to the class object.</param> protected ShellCommand(CLSCTX classContext, REGCLS classUse) : base(classContext, classUse) { }
[DllImport("ole32.dll", PreserveSig = false)] // HRESULTの戻り値を例外として受け取る protected static extern UInt32 CoRegisterClassObject( [In] ref Guid rclsid, [MarshalAs(UnmanagedType.Interface), In] IClassFactory pUnk, [In] CLSCTX dwClsContext, [In] REGCLS flags);
public ClassObjectRegistration(Guid clsid, IClassFactory factory, CLSCTX dwClsContext, REGCLS flags) { cookie = CoRegisterClassObject(clsid, factory, dwClsContext, flags); }
public static extern uint CoRegisterClassObject( [MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, [MarshalAs(UnmanagedType.Interface)] IClassFactory pUnk, CLSCTX dwClsContext, REGCLS flags);