wav可以用API,MP3就需要用控件或者用DIRECTX。http://community.csdn.net/Expert/topic/2697/2697981.xml?temp=.9674799

解决方案 »

  1.   

    一种方法是用Micro Media Player控件(只是播放声音,太浪费了)
    还有就是可以用DirectX
    <SDK>v1.1\Samples\Technologies\Interop\Basic\DirectX\DirectMusic
    有实例,调试时需要添加引用:COM中选DirectX 7 for Visual Basic Type Library
    不过他播放的是sty的声音文件
      

  2.   

    DirectX有些难啊,哪位做过的高人给指点一哈阿:)
    看了Brunhild的,发现用win32 api实现起来要容易些拉
    [DllImport("Winmm.dll")]
    public static extern long PlaySound(string name,long  module,long flag);
    [DllImport("winmm.dll")]
    private static extern long mciSendString(string lpstrCommand,string lpstrReturnString,long length,long hwndcallback);
    private string m_MusicName="";
    private void PlayMusic()
    {
    m_MusicName="\""+Tool.ReadInfo("promptmusicfile")+"\"";
    if(m_MusicName.Length==0)
    return;
    try
    {
    mciSendString(@"close " + m_MusicName,"",0,0);
    mciSendString(@"open " + m_MusicName,"",0,0);
    mciSendString(@"play " + m_MusicName ,"",0,0);
    }
    catch
    {
    }
    }
    private void StopMusic()
    {
    try
    {
    mciSendString(@"close " + m_MusicName,"",0,0);
    }
    catch{}
    }
    其中winmm.dll中对PlaySound的说明:
    Platforms: Win 32s, Win 95/98, Win NT PlaySound plays a waveform sound through the speakers. This sound could be a .wav file, a system event sound (such as the system startup sound), or a sound resource stored in an application. Note that when the function needs to play an application resource or a RAM-loaded sound, Visual Basic users must use the alternate declare of the function in order to pass the numeric identifier of the sound instead of a string. The function returns 0 if an error occured, or a non-zero value if successful. 
    对mciSendString的说明:
    mciGetErrorString obtains a textual description of an error raised by another Media Control Interface (MCI) function. Typically these errors are not the fault of the program. Rather, they are caused by "problems" with the device (for example, the MIDI driver is currently being used by another program, so your program's attempt to open it failed). The messages retrieved by this function are sufficient to tell the user what caused the error.