我写一个程序用到PlaySound函数,但是调用结束后,出现Project Project1.exe raised exception class EInvalidPointer with message 'Invalid pointer opertion'.Process stopped.Use Step or Run to continue.function PlaySound(pszSound: PChar; hmod: HMODULE; fdwSound: DWORD): BOOL; stdcall;
{$EXTERNALSYM PlaySoundA}函数原型:PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav有谁知道是怎么回事吗?
{$EXTERNALSYM PlaySoundA}函数原型:PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav有谁知道是怎么回事吗?
解决方案 »
- 在局域网内如何制做互相通信小程序
- 将字符串变量中的指定字符串删除,如从字符串变量('a','b','c','d','等','未知')删除'c',不知道在变量的位置
- Webbrowser1调用本地网页的属性时候发生“拒绝访问”,高手快来,小弟急用
- 关于delphi .net下数据库操作的问题
- 怎样将DELPHI里显示的繁体字转换成简体字??
- 如何让程序等待?
- 如何统计出memo里面的行数?
- 嵌入式框架中,用Dynamic定义方法,能否提升兼容性?
- 什么方法可以用程序实现向搜索引擎发送搜索命令?
- 如何给分,献给最先决决问题的人
- 右键点击ListView如何才能不改变选中状态?
- cxgrid cxbutton1.onclick:invalid property value
#define IDR_SELECT 100
#define IDR_EAT 100
#define IDR_GOTO 100const
cnt_SQUARE_SIZE = 56;{(270,102)}
ResID_Wave_Select = 300;
ResID_Wave_Move = 301;
ResID_Wave_Eat = 302;
ResID_Wave_Check = 303;
ResID_Wave_GameWin = 304;
ResID_Wave_GameOver = 305;PlaySound(MAKEINTRESOURCE(nResId), MainInstance, SND_ASYNC or SND_NOWAIT or SND_RESOURCE);
IDR_EAT WAVE DISCARDABLE "Eat.wav"
就是他们执行完毕后会报指针错误的。
{$R WaveResource.Res}{ TPlaySound }constructor TPlaySound.Create(const AName: string);
begin
FreeOnTerminate := True;
inherited Create(True);
FName := AName;
end;procedure TPlaySound.Execute;
begin
inherited;
MMSystem.PlaySound(PChar(FName), Hinstance, SND_RESOURCE or SND_SYNC);
end;
{$R WavWork.RES} //新加入的编译资源文件的指令
{ MyWav1 WAVE "D:\delphi\Demo\AutoGet\GetTask.wav"
MyWav2 WAVE "D:\delphi\Demo\AutoGet\Get.wav" }procedure TMainForm.AlertSound(S_Name: String);
begin
// 调用.wav文件
// PlaySound(PChar(S_Name),0,SND_FILENAME or SND_ASYNC);
//*/ 调用资源文件中的wav
PlaySound(PChar(S_Name),hInstance,Snd_ASync or Snd_Memory or snd_Resource);
end;//调用的时候直接
AlertSound('MyWav1');
我用的是PlaySound(PChar(S_Name),Hinstance,SND_RESOURCE OR SND_SYNC); 方式,有问题吗?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,MMSystem, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{$R sounds.res}
procedure TForm1.Button1Click(Sender: TObject);
var
l_str:string;
l_c1,l_c2,l_c3,l_c4,l_c5,l_c6,l_c7:String;
i:integer;
l_flag:integer; //标志位,是否读过yuan.wav
Num:real;
l_cc:String;
l_Currency:Currency;
m_bool:Boolean;
begin
//l_currency:=StrToCurr(Edit1.Text);
l_currency:=88; //例如读取88
l_str:=CurrToStr(l_currency);
Num:=StrToFloat(l_str);
l_flag:=0;
inherited;
{0~9.99数字读取}
if(Num<10) and (Num>=0)then
begin
l_c1:='c'+l_str[1];
l_c3:='c'+l_str[3];
l_c4:='c'+l_str[4];
if not ( l_str[4] in ['0'..'9']) then
begin
l_str[4]:='0';
end;
if not (l_str[3] in ['0'..'9']) then
begin
l_str[3]:='0';
end;
if StrToInt(l_str[1])<>0 then //第一位
begin
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC);
end
else
begin
if (StrToInt(l_str[3])=0) and (StrToInt(l_str[4])=0) then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC);
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
if (StrToInt(l_str[3])<>0) or (StrToInt(l_str[4])<>0) then
begin
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
l_flag:=l_flag+1;
end;
if StrToInt(l_str[3])<>0 then //第三位
begin
PlaySound(Pchar(l_c3),Hinstance,SND_RESOURCE OR SND_SYNC); //第三位
end
else
begin
if StrToInt(l_str[4])<>0 then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC)
else
if l_flag<1 then
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
if StrToInt(l_str[4])<>0 then //第四位
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC); //第四位
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end
end;
{10~99.99的数字读取 Eg:99.10} if (Num>=10) and (Num<100) then
begin
l_c1:='c'+ l_str[1]; //第一位
l_c2:='c'+ l_str[2]; //第二位
l_c4:='c'+ l_str[4]; //第四位
l_c5:='c'+ l_str[5]; //第五位
if not ( l_str[4] in ['0'..'9']) then
begin
l_str[4]:='0';
end;
if not (l_str[5] in ['0'..'9']) then
begin
l_str[5]:='0';
end;
PlaySound(Pchar(l_c1),Hinstance,SND_RESOURCE OR SND_SYNC); //第一位
PlaySound('c11',Hinstance,SND_RESOURCE OR SND_SYNC); //拾
if StrToInt(l_str[2])<>0 then
begin
PlaySound(Pchar(l_c2),Hinstance,SND_RESOURCE OR SND_SYNC); //第二位
end;
if (StrToInt(l_str[4])=0) and (StrToInt(l_str[5])=0) then
begin
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
l_flag:=1;
end;
if (StrToInt(l_str[4])<>0) or (StrToInt(l_str[5])<>0) then
begin
PlaySound('c17',Hinstance,SND_RESOURCE OR SND_SYNC); //点.wav
l_flag:=l_flag+1;
end;
if StrToInt(l_str[4])<>0 then //第四位
begin
PlaySound(Pchar(l_c4),Hinstance,SND_RESOURCE OR SND_SYNC);
if StrToInt(l_str[5])=0 then
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end
else
begin
if StrToInt(l_str[5])<>0 then
PlaySound('c18',Hinstance,SND_RESOURCE OR SND_SYNC)
else
if l_flag<1 then
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
if StrToInt(l_str[5])<>0 then //第五位
begin
PlaySound(Pchar(l_c5),Hinstance,SND_RESOURCE OR SND_SYNC);
PlaySound('c16',Hinstance,SND_RESOURCE OR SND_SYNC); //元.wav
end;
end;
end.