求助:关于Delphi 7 怎样播放WAV资源 我已经将WAV文件加入到SOUND.RES文件中,请问应该怎么播放它?抱歉,刚起步,不是很明白.各位能否说得详细一点.最好有实例代码.先谢谢啦. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 PlaySound('资源里面的名字',hInstance,Snd_ASync or Snd_Memory or snd_Resource);在implementation下面加{$R sound.RES} 直接用wavefile控件,然后Name.play 用playsound,可以控制同步或异步模式,俺就是这么用的,详情查看PlaySound的help 给你个示例代码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); //点击播放按钮playbeginsndplaysound(ptrSound,snd_async or snd_Memory);//播放指定声音end;procedure TForm1.exitClick(Sender: TObject); //点击按钮退出begin Close;end;end. {$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); {$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); hjkto进来接分 delphi7如何实现在build或run运行之前执行我的exe? 今天(7月15)农历生日, 放分1 买过Borland产品的给出出主意 Delphi中操作Excel的问题! 急啊,高分回报,如何给word中的 文件菜单-》属性-》类别传递一个字符串 难题,在线等待!!!!!!!!!!!!!!!!!!!! ★★★★★★★★表哥考研完了,祝他顺利通过!★★★★★★★★ 问个送分的问题, 急!!!!编译出错的问题。Undeclared identifier: 'PByte' Vista出来了, delphi是不是已经走到尽头了? ado动态链接sql数据库
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.
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);
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);