[DllImport("winmm.dll", SetLastError = true)]
public static extern uint waveOutGetNumDevs();
Returns the number of devices. A return value of zero means that no devices are present or that an error occurred.
http://msdn.microsoft.com/en-us/library/dd743860(v=vs.85).aspx