예제 #1
0
        public static bool ShowFormatChooseDialog(IntPtr ownerWindowHandle, string windowTitle, AcmFormatEnumFlags enumFlags, WaveFormat enumFormat, out WaveFormat selectedFormat, out string selectedFormatDescription, out string selectedFormatTagDescription)
        {
            AcmFormatChoose acmFormatChoose = default(AcmFormatChoose);

            acmFormatChoose.structureSize     = Marshal.SizeOf(acmFormatChoose);
            acmFormatChoose.styleFlags        = AcmFormatChooseStyleFlags.None;
            acmFormatChoose.ownerWindowHandle = ownerWindowHandle;
            int num = 200;

            acmFormatChoose.selectedWaveFormatPointer  = Marshal.AllocHGlobal(num);
            acmFormatChoose.selectedWaveFormatByteSize = num;
            acmFormatChoose.title                 = windowTitle;
            acmFormatChoose.name                  = null;
            acmFormatChoose.formatEnumFlags       = enumFlags;
            acmFormatChoose.waveFormatEnumPointer = IntPtr.Zero;
            if (enumFormat != null)
            {
                IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(enumFormat));
                Marshal.StructureToPtr(enumFormat, intPtr, false);
                acmFormatChoose.waveFormatEnumPointer = intPtr;
            }
            acmFormatChoose.instanceHandle = IntPtr.Zero;
            acmFormatChoose.templateName   = null;
            MmResult mmResult = AcmInterop.acmFormatChoose(ref acmFormatChoose);

            selectedFormat               = null;
            selectedFormatDescription    = null;
            selectedFormatTagDescription = null;
            if (mmResult == MmResult.NoError)
            {
                selectedFormat               = WaveFormat.MarshalFromPtr(acmFormatChoose.selectedWaveFormatPointer);
                selectedFormatDescription    = acmFormatChoose.formatDescription;
                selectedFormatTagDescription = acmFormatChoose.formatTagDescription;
            }
            Marshal.FreeHGlobal(acmFormatChoose.waveFormatEnumPointer);
            Marshal.FreeHGlobal(acmFormatChoose.selectedWaveFormatPointer);
            if (mmResult != MmResult.AcmCancelled && mmResult != MmResult.NoError)
            {
                throw new MmException(mmResult, "acmFormatChoose");
            }
            return(mmResult == MmResult.NoError);
        }
예제 #2
0
 public static extern MmResult acmFormatChoose(ref AcmFormatChoose formatChoose);