| 发表于:2007-01-23 10:25:29 楼主 |
public class sound { public sound() { // // todo: 在此处添加构造函数逻辑 // } 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 */ } |
|
|
|
|