背景音乐用midi格式,声音用wav或其他

解决方案 »

  1.   

    试一试用Playsound函数。例子如下:
    unit Main;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ExtCtrls, GradBtn;type
      TMForm = class(TForm)
        WinMe: TImage;
        AboutBt: TGradBtn;
        SoundBt: TGradBtn;
        procedure SoundBtClick(Sender: TObject);
        procedure AboutBtClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      MForm: TMForm;implementation
    uses mmsystem;  //引用mmsystem单元,以便正确调用函数PlaySound。{$R *.DFM}
    {$R SoundFiles.RES}  //导入带有声音的资源文件:SoundFiles.res,以便调用。procedure TMForm.SoundBtClick(Sender: TObject);
    begin
        PlaySound('MS',hInstance,SND_ASYNC or SND_RESOURCE);
        //使用Windows的标准API函数:PlaySound播放声音文件,
        //其中,MS是资源文件里的Wav文件的名称,hInstance是
        //表示需要引用资源文件,而,SND_ASYNC是表示需要异
        //步播放文件,SND_RESOURCE表示声音来自一个资源文件。
    end;