我已经将WAV文件加入到SOUND.RES文件中,请问应该怎么播放它?
抱歉,刚起步,不是很明白.各位能否说得详细一点.最好有实例代码.先谢谢啦.

解决方案 »

  1.   

    PlaySound('资源里面的名字',hInstance,Snd_ASync or Snd_Memory or snd_Resource);在implementation下面加{$R sound.RES}
      

  2.   

    直接用wavefile控件,然后Name.play
      

  3.   

    用playsound,可以控制同步或异步模式,俺就是这么用的,详情查看PlaySound的help
      

  4.   

    给你个示例代码unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls,MMSystem;//MMSysTem是Windows API 的接口,里面有API函数的声明type
      TForm1 = class(TForm)
        play: TButton;
        Label1: TLabel;
        exit: TButton;
        procedure FormCreate(Sender: TObject);
        procedure playClick(Sender: TObject);
        procedure exitClick(Sender: TObject);
      private
             PtrSound : PChar;
             Sound_hRes: THandle;    { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}
    //把资源文件声明在下面,这里就是你的那个资源文件
    {$R SOUND.RES} procedure TForm1.FormCreate(Sender: TObject);
    var SoundInfo : THandle;
    begin
      SoundInfo := FindResource(HInstance,'SOUND','WAV');
      //查找到指定名称和格式这里是 Sound 和 WAV
      Sound_hRes := LoadResource(HInstance, SOundInfo);
      //掉入资源信息
      if Sound_hRes > 32 then
      begin
        ptrSound:=LockResource(Sound_hRes);
        //锁定资源
      end;
    end;procedure TForm1.playClick(Sender: TObject);   //点击播放按钮play
    begin
    sndplaysound(ptrSound,snd_async or snd_Memory);
    //播放指定声音
    end;procedure TForm1.exitClick(Sender: TObject);  //点击按钮退出
    begin
      Close;
    end;end.
      

  5.   

    {$R sound.res} 在此声明了Sound.res资源文件var
      hResInfo: THandle;}
    begin
      hResInfo := Findresource(HInstance, 'sound', 'wav');
      hRes := LoadResource(HInstance, hResInfo);
      if hRes > 32 then
        PtrSound := LockResource(hRes);
    SndPlaySound(PtrSound, Snd_Async or Snd_Memory);
      

  6.   

    {$R sound.res} 在此声明了Sound.res资源文件var
      hResInfo: THandle;}
    begin
      hResInfo := Findresource(HInstance, 'sound', 'wav');
      hRes := LoadResource(HInstance, hResInfo);
      if hRes > 32 then
        PtrSound := LockResource(hRes);
    SndPlaySound(PtrSound, Snd_Async or Snd_Memory);