OleCreate (ole32)
Last changed: anonymous

.
Summary
Invokes a new property frame.

C# Signature:

[DllImport("oleaut32.dll", PreserveSig = false)]
static extern void OleCreatePropertyFrame(IntPtr hwndOwner, int x, int y,
    [MarshalAs(UnmanagedType.LPWStr)] string lpszCaption,
    int cObjects, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
    int cPages, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
    int lcid, int dwReserved, int lpvReserved);

VB Signature:

Declare Function OleCreatePropertyFrame Lib "ole32.dll" (TODO) As TODO

VB.Net Signature:

    Declare Function OleCreatePropertyFrame Lib "oleaut32" _
    (ByVal hwndOwner As IntPtr, _
    ByVal x As Int32, _
    ByVal y As Int32, _
    <MarshalAs(UnmanagedType.LPWStr)> _
    ByVal lpszCaption As String, _
    ByVal cObjects As Int32, _
    <MarshalAs(UnmanagedType.Interface, ArraySubType:=UnmanagedType.IUnknown)> _
    ByRef ppUnk As Object, _
    ByVal cPages As Int32, _
    ByVal pPageClsID As Int32, _
    ByVal lcid As Int32, _
    ByVal dwReserved As Int32, _
    ByVal pvReserved As IntPtr) As Integer

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

This should be under oleaut32.dll!

Tips & Tricks:

Please add some!

Sample Code:

// complete example at http://www.codeproject.com/Articles/34663/DirectShow-Examples-for-Using-SampleGrabber-for-Gr

using System;

using System.Runtime.InteropServices;

using System.Windows.Forms;

using DirectShowLib;

namespace Utilities.DirectShow.Capture

{

    /// <summary>
    ///  Property pages for a DirectShow filter (e.g. hardware device). These
    ///  property pages do not support persisting their settings.
    /// </summary>
    public class DirectShowPropertyPage : PropertyPage
    {
        /// <summary> COM ISpecifyPropertyPages interface </summary>
        protected ISpecifyPropertyPages specifyPropertyPages;

        /// <summary> Constructor </summary>
        public DirectShowPropertyPage(string name, ISpecifyPropertyPages specifyPropertyPages)
        {
            Name = name;
            SupportsPersisting = false;
            this.specifyPropertyPages = specifyPropertyPages;
        }

        /// <summary>
        ///  Show the property page. Some property pages cannot be displayed
        ///  while previewing and/or capturing.
        /// </summary>
        public override void Show(Control owner)
        {
            DsCAUUID cauuid = new DsCAUUID();
            try
            {
                int hr = specifyPropertyPages.GetPages( out cauuid );
                if ( hr != 0 ) Marshal.ThrowExceptionForHR( hr );

        object[] o = new object[] { specifyPropertyPages };
        Guid[] guidarray = cauuid.ToGuidArray();
        int nelements = guidarray.Length;

        hr = OleCreatePropertyFrame(owner.Handle, 0, 0, Name, o.Length,
            o, nelements, guidarray, 0, 0, 0);
            }
            finally
            {
                if( cauuid.pElems != IntPtr.Zero )
                    Marshal.FreeCoTaskMem( cauuid.pElems );
            }
        }

        /// <summary> Release unmanaged resources </summary>
        public new void Dispose()
        {
            if ( specifyPropertyPages != null )
                Marshal.ReleaseComObject( specifyPropertyPages ); specifyPropertyPages = null;
        }

    [DllImport("oleaut32.dll", CharSet=CharSet.Unicode, ExactSpelling=true) ]
    static extern int OleCreatePropertyFrame(IntPtr hwndOwner,
        int x,
        int y,
        [MarshalAs(UnmanagedType.LPWStr)] string lpszCaption,
        int cObjects,
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
        int cPages,
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
        int lcid,
        int dwReserved,
        int lpvReserved);

    }

}

Documentation

Changes:

7/6/2012 Dan Woerner : Changed olepro32.dll to oleaut32.dll because olepro32 doesn't work for x64, also changed the uint/UINT32/(and IntPtr reserved) to int because they are easier to deal with