December 2005 - Posts

A better MIXERCAPS definition for pinvoke ...

I've been playing with the Mixer API nowadays and try to call it from .NET as well. I found many on the web the following struct definition to call mixerGetDevCapsA

    public struct MIXERCAPS

    {

        public int wMid;

        public int wPid;

        public int vDriverVersion;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAXPNAMELEN)]

        public string szPname;

        public int fdwSupport;

        public int cDestinations;

    }

but when I checked out the results returned I quickly realized that it is not correct and fields are all mixed up, so I created one where the offsets for fields specified as well:

    public static extern int mixerGetDevCaps(int uMxId, ref MIXERCAPS

    pmxcaps, int cbmxcaps);

 

    [StructLayout(LayoutKind.Explicit)]

    public struct MIXERCAPS

    {

        [FieldOffset(0)]

        public short wMid;

        [FieldOffset(2)]

        public short wPid;

        [FieldOffset(4)]

        public int vDriverVersion;

        [FieldOffset(8)]

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAXPNAMELEN)]

        public string szPname;

        [FieldOffset(8 + MAXPNAMELEN)]

        public int fdwSupport;

        [FieldOffset(8 + MAXPNAMELEN + 4)]

        public int cDestinations;

    };

Feedmap.net

putting my blog on the map. This is spaceholder now and this would be normally part of my template

Local blogroll