解决办法:
  我们在net framework(C#)环境下可以通过调用winmm.dll库文件中的 waveOutGetNumDevs 和 midiOutGetNumDevs() 函数.
 waveOutGetNumDevs()的返回值表示当前机器上波形输出设备个数
 midiOutGetNumDevs()的返回值表示当前机器上MIDI输出设备个数

 示例代码:
  1.引入命名空间:
 using System.Runtime.InteropServices;
  2.引入winmm.dll库文件
 [ DllImport( "Winmm.dll", CharSet=CharSet.Auto )]
  public static extern int waveOutGetNumDevs();
  [ DllImport( "Winmm.dll", CharSet=CharSet.Auto )]
  public static extern int midiOutGetNumDevs();
  private void btnBegin_Click(object sender, System.EventArgs e)
  {
   try
   {
   
    if(waveOutGetNumDevs() > 0 && midiOutGetNumDevs() >0 )
    {
     MessageBox.Show("系统检测到您当前机器已安装声卡!");
    }
    else
    {
     MessageBox.Show("系统检测到您当前机器未安装声卡!");
    }
   }
   catch(Exception ex)
   {
    MessageBox.Show("检测当前机器是否安装声卡失败: "+ex.Message);
   }
  }
posted on 2008-06-26 13:35  Thunderdanky  阅读(280)  评论(0)    收藏  举报