你可以用TMedieplayer控件,或者用API函数

解决方案 »

  1.   

    BOOL PlaySound( LPCSTR pszSound, HMODULE hmod,  DWORD fdwSound );
      

  2.   

    playsound在vc下我会用,但在delphi中怎样用啊?
      

  3.   

    我在Delphi中用过,只要加个头文件就可以直接引用,具体什么头文件我给忘了,
    我帮你找找。
      

  4.   

    function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall;
    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]
    祝你好运!
      

  5.   

    终于找到了,引用"MMSystem" 单元
      

  6.   

    我刚用delphi,请见谅
    小弟不知道mmsystem在何处引用啊?
    还有关于:
    function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall;
    不能直接声明啊,
    调用dll时后面要接external '**' name '**';这里是不是也要添加些东西啊?
      

  7.   

    在system中的winmm.dll中
    playsound,应用的时候要加入
    function PlaySound(pszSound:char;hmod:HMODULE;fdwSound:DWORD):bool:stdcall;
    external 'winmm.dll' name 'playsound';
      

  8.   

    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.
      

  9.   

    另外在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就行了
      

  10.   

    delphi下好像不支持playsound呀,fdwsound中的SND_FILENAME它不识别
      

  11.   

    我是用ExpandfileName(listbox1.items[i])获得的文件名,string
      这三种都用不了,请问该如何转换?
      

  12.   

    uses mmsystem;
    ...
      Playsound(PChar(ExpandfileName(listbox1.items[i])), ...);
    ...
      

  13.   

    windows提供了playsound api呀,
      

  14.   

    windows提供了playsound api呀,
      

  15.   

    PlaySound不就是API函数吗,Delphi也可以像VB一样直接调用的。至于出现的种种问题,也就是Uses 部分啦。 mmsystem,还有一些常量定义单元好像是Win32API之类的