/// <summary> /// Get the input device name from device id. /// </summary> /// <param name="deviceId">Device id.</param> /// <param name="prodName">Returns device name.</param> /// <returns>MMSYSERR.</returns> private static MMSYSERR _GetInputDeviceName(uint deviceId, ref string prodName) { var caps = new WaveInCaps(); MMSYSERR result = waveInGetDevCaps(deviceId, out caps, (uint)Marshal.SizeOf(caps)); // system function if (result != MMSYSERR.NOERROR) { return(result); } prodName = new string(caps.szPname); if (prodName.Contains("(") && !(prodName.Contains(")"))) { prodName = prodName.Substring(0, prodName.IndexOf("(")); } else if (prodName.Contains(")")) { if (prodName.IndexOf(")") > 8) { prodName = prodName.Substring(0, prodName.IndexOf(")") + 1); } } return(MMSYSERR.NOERROR); }
private static extern MMSYSERR waveInGetDevCaps(uint uDeviceID, out WaveInCaps pwic, uint cbwic);