Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

mixerSetControlDetails (winmm)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("winmm.dll")]
static extern Int32 mixerSetControlDetails(IntPtr hmxobj,
   ref MixerControlDetails pmxcd, UInt32 fdwDetails);

VB Signature:

Declare Function mixerSetControlDetails Lib "winmm.dll" (ByVal hmxobj As IntPtr, ByVal pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Integer) As Integer

User-Defined Types:

C# Struct

The winmm dll may not execute properly on 64-bit systems. Consequently, the StructLayout must be Sequential, with CharSet = Ansi, and Pack = 4. This particular type has some special layout considerations (the c union keyword) which typically means developers would use the explicit layout. However, the explicit layout breaks down on 64-bit systems for any type with an IntPtr in the type. Consequently, the C# types have been redesigned to use Sequential layout so that they will automatically adjust to 64-bit systems. This means private fields with public properties which perform the gunky work of making it look like there is a union.

Structure MIXERCONTROLDETAILS
     Dim cbStruct As Integer
     Dim dwControlID As Integer
     Dim cChannels As Integer
     Structure u ' A union
     Dim hWndOwner As IntPtr
     Dim cMultipleItems As Integer
     End Structure
     Dim cbDetails As Integer
     Dim paDeatails As IntPtr
End Structure

Notes:

None.

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 4)]
public struct MIXERCONTROL
{
     private UInt32 cbStruct;
     private UInt32 dwControlID;
     private UInt32 dwControlType;
     private UInt32 fdwControl;
     private UInt32 cMultipleItems;
     [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MixerXPNative.MIXER_SHORT_NAME_CHARS)]
     private string szShortName;
     [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MixerXPNative.MIXER_LONG_NAME_CHARS)]
     private string szName;
     public MIXERCONTROL_BOUNDS Bounds;
     public MIXERCONTROL_METRICS Metrics;

     #region Properties

     /// <summary>size in bytes of <see cref="MIXERCONTROL">MIXERCONTROL</see></summary>
     public UInt32 StructSize
     {
        get { return this.cbStruct; }
        set { this.cbStruct = value; }
     }
     /// <summary></summary>
     public UInt32 ControlID
     {
        get { return this.dwControlID; }
        set { this.dwControlID = value; }
     }
     /// <summary>MIXERCONTROL_CONTROLTYPE_xxx</summary>
     public MIXERCONTROL_CONTROLTYPE ControlType
     {
        get { return (MIXERCONTROL_CONTROLTYPE)this.dwControlType; }
        set { this.dwControlType = (UInt32)value; }
     }
     /// <summary>MIXERCONTROL_CONTROLF_xxx</summary>
     public MIXERCONTROL_CONTROLF Control
     {
        get { return (MIXERCONTROL_CONTROLF)this.fdwControl; }
        set { this.fdwControl = (uint)value; }
     }
     /// <summary>if MIXERCONTROL_CONTROLF_MULTIPLE set</summary>
     public UInt32 MultipleItems
     {
        get { return this.cMultipleItems; }
        set { this.cMultipleItems = value; }
     }
     /// <summary></summary>
     public String ShortName
     {
        get { return this.szShortName; }
        set { this.szShortName = value; }
     }
     /// <summary></summary>
     public String Name
     {
        get { return this.szName; }
        set { this.szName = value; }
     }

     #endregion
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 4)]
public struct MIXERCONTROL_BOUNDS
{
     private Int32 lMinimum;
     private Int32 lMaximum;
     //public uint dwMinimum; // Unioned with lMinimum
     //public uint dwMaximum; // Unioned with lMaximum
     //public uint dwReserved1; // Unioned with lMinimum
     //public uint dwReserved2; // Unioned with lMaximum
     private UInt32 dwReserved3;
     private UInt32 dwReserved4;
     private UInt32 dwReserved5;
     private UInt32 dwReserved6;

     #region Properties

     /// <summary>signed minimum for this control</summary>
     public Int32 Minimum
     {
        get { return this.lMinimum; }
        set { this.lMinimum = value; }
     }
     /// <summary>signed maximum for this control</summary>
     public Int32 Maximum
     {
        get { return this.lMaximum; }
        set { this.lMaximum = value; }
     }
     /// <summary>unsigned minimum for this control</summary>
     public UInt32 UnsignedMinimum
     {
        get { return (uint)this.lMinimum; }//TODO: something different
        set { this.lMinimum = (int)value; }
     }
     /// <summary>unsigned maximum for this control</summary>
     public UInt32 UnsignedMaximum
     {
        get { return (uint)this.lMaximum; }//TODO: something different
        set { this.lMaximum = (int)value; }
     }
     /// <summary></summary>
     public UInt32 Reserved1
     {
        get { return (uint)this.lMinimum; }//TODO: something different
        set { this.lMinimum = (int)value; }
     }
     /// <summary></summary>
     public UInt32 Reserved2
     {
        get { return (uint)this.lMaximum; }//TODO: something different
        set { this.lMaximum = (int)value; }
     }
     /// <summary></summary>
     public UInt32 Reserved3
     {
        get { return this.dwReserved3; }
        set { this.dwReserved3 = value; }
     }
     /// <summary></summary>
     public UInt32 Reserved4
     {
        get { return this.dwReserved4; }
        set { this.dwReserved4 = value; }
     }
     /// <summary></summary>
     public UInt32 Reserved5
     {
        get { return this.dwReserved5; }
        set { this.dwReserved5 = value; }
     }
     /// <summary></summary>
     public UInt32 Reserved6
     {
        get { return this.dwReserved6; }
        set { this.dwReserved6 = value; }
     }

     #endregion
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 4)]
public struct MIXERCONTROL_METRICS
{
     private UInt32 cSteps;
     //private UInt32 cbCustomData; //Unioned with cSteps
     //private UInt32 dwReserved1; //Unioned with cSteps
     private UInt32 dwReserved2;
     private UInt32 dwReserved3;
     private UInt32 dwReserved4;
     private UInt32 dwReserved5;
     private UInt32 dwReserved6;

     #region Properties

     /// <summary># of steps between min & max</summary>
     public UInt32 Steps
     {
        get { return this.cSteps; }
        set { this.cSteps = value; }
     }
     /// <summary>size in bytes of custom data</summary>
     public UInt32 CustomData
     {
        get { return this.cSteps; }
        set { this.cSteps = value; }
     }
     /// <summary>!!! needed? we have cbStruct....</summary>
     public UInt32 Reserved1
     {
        get { return this.cSteps; }//TODO: something different
        set { this.cSteps = value; }
     }
     /// <summary>!!! needed? we have cbStruct....</summary>
     public UInt32 Reserved2
     {
        get { return this.dwReserved2; }
        set { this.dwReserved2 = value; }
     }
     /// <summary>!!! needed? we have cbStruct....</summary>
     public UInt32 Reserved3
     {
        get { return this.dwReserved3; }
        set { this.dwReserved3 = value; }
     }
     /// <summary>!!! needed? we have cbStruct....</summary>
     public UInt32 Reserved4
     {
        get { return this.dwReserved4; }
        set { this.dwReserved4 = value; }
     }
     /// <summary>!!! needed? we have cbStruct....</summary>
     public UInt32 Reserved5
     {
        get { return this.dwReserved5; }
        set { this.dwReserved5 = value; }
     }
     /// <summary>!!! needed? we have cbStruct....</summary>
     public UInt32 Reserved6
     {
        get { return this.dwReserved6; }
        set { this.dwReserved6 = value; }
     }

     #endregion
}

VB Struct

Structure MIXERCONTROLDETAILS
     Dim cbStruct As Integer
     Dim dwControlID As Integer
     Dim cChannels As Integer
     Structure u ' A union
     Dim hWndOwner As IntPtr
     Dim cMultipleItems As Integer
     End Structure
     Dim cbDetails As Integer
     Dim paDeatails As IntPtr
End Structure

Notes:

None.

Tips & Tricks:

The fdwDetails parameter can be composed constants from two distinct enumerations, one of which is used frequently in the winmm library, and the other constant is only used with this method. Consequently, you should wrap up the method definition so that it is easier to use, and more consistent. In the following example, the actual extern is private, while the public static method lists both enums to callers.

Please add some!

[DllImport("winmm.dll", CharSet = CharSet.Unicode)]
private static extern Int32 mixerSetControlDetails(IntPtr hmxobj, ref MIXERCONTROLDETAILS pmxcd, uint fdwDetails);

public static Int32 mixerSetControlDetails(IntPtr hmxobj, ref MIXERCONTROLDETAILS pmxcd, MIXER_OBJECTF fdwDetails, MIXER_SETCONTROLDETAILSF setControlDetails)
{
     uint flags = ((uint)fdwDetails | (uint)setControlDetails);
     return mixerSetControlDetails(hmxobj, ref pmxcd, flags);
}

public enum MIXER_OBJECTF : uint
{
     HANDLE   = 0x80000000u,
     MIXER    = 0x00000000u,
     HMIXER   = (HANDLE | MIXER),
     WAVEOUT  = 0x10000000u,
     HWAVEOUT = (HANDLE | WAVEOUT),
     WAVEIN   = 0x20000000u,
     HWAVEIN  = (HANDLE | WAVEIN),
     MIDIOUT  = 0x30000000u,
     HMIDIOUT = (HANDLE | MIDIOUT),
     MIDIIN   = 0x40000000u,
     HMIDIIN  = (HANDLE | MIDIIN),
     AUX      = 0x50000000u,
}
public enum MIXER_SETCONTROLDETAILSF : uint
{
     VALUE      = 0x00000000u,
     CUSTOM     = 0x00000001u,

     QUERYMASK  = 0x0000000Fu,
}

Sample Code:

Please add some!

Alternative Managed API:

The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides a Mixer control.

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions