我刚用delphi,请见谅 小弟不知道mmsystem在何处引用啊? 还有关于: function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall; 不能直接声明啊, 调用dll时后面要接external '**' name '**';这里是不是也要添加些东西啊?
在system中的winmm.dll中 playsound,应用的时候要加入 function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall; external 'winmm.dll' name 'playsound';
unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM} //在下面加上两句 uses MMSystem ; end.或者是 unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, MMSystem;type TForm1 = class(TForm) private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}end.
另外在Delphi中有三个名字可以用: function sndPlaySoundA(lpszSoundName: PAnsiChar; uFlags: UINT): BOOL; stdcall; function sndPlaySoundW(lpszSoundName: PWideChar; uFlags: UINT): BOOL; stdcall; function sndPlaySound(lpszSoundName: PChar; uFlags: UINT): BOOL; stdcall; 只要将MMsystem照我刚才的方法加进去,然后直接使用sndPlaysound就行了
我帮你找找。
pszSound:指定文件名
hmod:表示含有声音资源的可执行文件的句柄,一般为0
fdwSound:播放模式,其值有
SND_APPLICATION:使用一特定程序集播放声音
SND_ALLAS:
SND_ALLAS_ID:
SND_FILENAME:
SND_NOWAITE:
SND_PURGE:
SND_RESOURCE:
SND_ASYNS:
SND_LOOP:
SND_MEMORY:
SND_NODEFAULT:
SND_NOSTOP:
SND_SYNC:
顾名思义,自已试一试吧!
如还有问题,可与我联系统:
[email protected]
[email protected]
祝你好运!
小弟不知道mmsystem在何处引用啊?
还有关于:
function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall;
不能直接声明啊,
调用dll时后面要接external '**' name '**';这里是不是也要添加些东西啊?
playsound,应用的时候要加入
function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall;
external 'winmm.dll' name 'playsound';
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
//在下面加上两句
uses
MMSystem ;
end.或者是
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MMSystem;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}end.
function sndPlaySoundA(lpszSoundName: PAnsiChar; uFlags: UINT): BOOL; stdcall;
function sndPlaySoundW(lpszSoundName: PWideChar; uFlags: UINT): BOOL; stdcall;
function sndPlaySound(lpszSoundName: PChar; uFlags: UINT): BOOL; stdcall;
只要将MMsystem照我刚才的方法加进去,然后直接使用sndPlaysound就行了
这三种都用不了,请问该如何转换?
...
Playsound(PChar(ExpandfileName(listbox1.items[i])), ...);
...