乞丐中的霸主(ぃ枫.net)(天行健,君子以自强不息;地势坤,君子以厚德载物! -《周易》)QQ讨论群(交流EVC++,VC++,USB驱动程序开发,上下机位通讯,无线网络通讯技术,Mobile开发)帮主QQ号:414885058

C#,C++ 学习

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
using  System;
using  System.Runtime.InteropServices;

namespace  tonysound 
{
    
public   class  Sound 
    
{
        
public   static   void  Play(  string  strFileName, PlaySoundFlags soundFlags) 
        
{
            PlaySound( strFileName, IntPtr.Zero, soundFlags);
            
//  passes to Playsound the filename and a pointer
            
//  to the Flag
        }


        [DllImport(
" winmm.dll " )]  // inports the winmm.dll used for sound
         private   static   extern   bool  PlaySound(  string  szSound, IntPtr hMod, PlaySoundFlags flags );
    }


    [Flags] 
// enumeration treated as a bit field or set of flags
     public   enum  PlaySoundFlags:  int  
    
{

        SND_SYNC 
=   0x0000 /*  play synchronously (default)  */
        SND_ASYNC 
=   0x0001 /*  play asynchronously  */
        SND_NODEFAULT 
=   0x0002 /*  silence (!default) if sound notfound  */
        SND_LOOP 
=   0x0008 /*  loop the sound until nextsndPlaySound  */
        SND_NOSTOP 
=   0x0010 /*  don't stop any currently playingsound  */
        SND_NOWAIT 
=   0x00002000 /*  don't wait if the driver is busy  */
        SND_FILENAME 
=   0x00020000 /*  name is file name  */
        SND_RESOURCE 
=   0x00040004   /*  name is resource name or atom  */  
    }
 
}


特点就是简单小巧,只能在windows上用啊.
posted on 2008-07-28 11:39  arvin2012  阅读(389)  评论(0)    收藏  举报