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

waveOutOpen (coredll)
 

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for waveOutOpen in other DLLs exists, click on Find References to the right.

.
Summary
TODO - a short description

C# Signature:

[DllImport ("coredll.dll", EntryPoint="waveOutOpen", SetLastError=true)]
public static extern int waveOutOpen(out IntPtr t, int id, WaveFormatEx pwfx, IntPtr dwCallback, int dwInstance, int fdwOpen);

VB Signature:

(TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Taken from openNetCF in OpenNETCF.Win32.Wave

Tips & Tricks:

Some of the sample code on MSDN as part of the PInvoke library gave the dllimport syntax like this:

[DllImport ("coredll.dll")]

private static extern Wave.MMSYSERR waveOutOpen(ref IntPtr phwo, uint uDeviceID, Wave.WAVEFORMATEX pwfx, IntPtr dwCallback, uint dwInstance, uint fdwOpen);

I could only get this to work by changing the following:

Wave.WAVEFORMATEX pwfx => ref WAVEFORMATEX pwfx // reference pointer rather than the format struct.

Sample Code:

using System;

using System.Data;

using System.Runtime.InteropServices;

namespace waveoutopen {

    class Tester
    {
        static void Main(string[] args)
        {
            Tester t = new Tester();
            t.Run();
        }
        public void Run()
        {
            WAVEFORMATEX testFormat = new WAVEFORMATEX();    
            testFormat.wFormatTag = 1;
            testFormat.wBitsPerSample = 16;   // 8,16
            testFormat.nChannels = 2;
            testFormat.nSamplesPerSec = 44100;
            testFormat.nBlockAlign = (ushort)(testFormat.nChannels *
                (testFormat.wBitsPerSample / 8));
            testFormat.nAvgBytesPerSec = (testFormat.nSamplesPerSec *
                testFormat.nBlockAlign);
            testFormat.cbSize = 0;

            IntPtr m_hwi = IntPtr.Zero;
            IntPtr hwnd = IntPtr.Zero;

            MMSYSERR result = waveOutOpen(ref m_hwi, WAVE_MAPPER,
                ref testFormat, 0, 0, 0);

            Console.WriteLine("and the result of open is {0}",result.ToString());
        }
        private const int MMSYSERR_BASE = 0;
        public const uint WAVE_MAPPER = unchecked((uint)(-1));
        public enum MMSYSERR : int
        {
            NOERROR = 0,
            ERROR = (MMSYSERR_BASE + 1),
            BADDEVICEID = (MMSYSERR_BASE + 2),
            NOTENABLED = (MMSYSERR_BASE + 3),
            ALLOCATED = (MMSYSERR_BASE + 4),
            INVALHANDLE = (MMSYSERR_BASE + 5),
            NODRIVER = (MMSYSERR_BASE + 6),
            NOMEM = (MMSYSERR_BASE + 7),
            NOTSUPPORTED = (MMSYSERR_BASE + 8),
            BADERRNUM = (MMSYSERR_BASE + 9),
            INVALFLAG = (MMSYSERR_BASE + 10),
            INVALPARAM = (MMSYSERR_BASE + 11),
            HANDLEBUSY = (MMSYSERR_BASE + 12),
            INVALIDALIAS = (MMSYSERR_BASE + 13),
            BADDB = (MMSYSERR_BASE + 14),
            KEYNOTFOUND = (MMSYSERR_BASE + 15),
            READERROR = (MMSYSERR_BASE + 16),
            WRITEERROR = (MMSYSERR_BASE + 17),
            DELETEERROR = (MMSYSERR_BASE + 18),
            VALNOTFOUND = (MMSYSERR_BASE + 19),
            NODRIVERCB = (MMSYSERR_BASE + 20),
            LASTERROR = (MMSYSERR_BASE + 20),
            BADFORMAT = (MMSYSERR_BASE + 32)
        }
        [DllImport ("coredll.dll")]
        private static extern MMSYSERR waveOutOpen(
            ref IntPtr phwo,
            uint uDeviceID,
            ref WAVEFORMATEX pwfx,
            uint dwCallback,
            uint dwInstance,
            uint fdwOpen
            );
        [StructLayout(LayoutKind.Sequential)]
        public unsafe struct WAVEFORMATEX
        {      
            public ushort wFormatTag;
            public ushort nChannels;
            public uint nSamplesPerSec;
            public uint nAvgBytesPerSec;
            public ushort nBlockAlign;
            public ushort wBitsPerSample;
            public ushort cbSize;          
        }
    }

}

Documentation
waveOutOpen on MSDN

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
Find References
Show Printable Version
Revisions