我需要播放一个wav文件作为系统声音'在Windows 7中,我在互联网上发现了各种信息,指出通过p / invoke使用winmm.dll播放声音,并设置了SND_SYSTEM标志。
我找到的每个例子都在其PlaySoundFlags枚举中省略了SND_SYSTEM的定义。我已经在网上查看了mmsystem.h的各种副本,但它们似乎都没有声明它。
如果可以,请提供SND_标志的完整枚举,包括SND_SYSTEM。如果做不到这一点,那么指向mmsystem.h头文件的Windows 7版本的链接将非常有用。
环境是Visual C#2017。
答案 0 :(得分:0)
如果您安装了Windows平台SDK,则可以获取所需的头文件。
在windows 10平台SDK中,值在playsoundapi.h中定义(从mmsystem.h引用)
#define SND_SYNC 0x0000 /* play synchronously (default) */
#define SND_ASYNC 0x0001 /* play asynchronously */
#define SND_NODEFAULT 0x0002 /* silence (!default) if sound not found */
#define SND_MEMORY 0x0004 /* pszSound points to a memory file */
#define SND_LOOP 0x0008 /* loop the sound until next sndPlaySound */
#define SND_NOSTOP 0x0010 /* don't stop any currently playing sound */
#define SND_NOWAIT 0x00002000L /* don't wait if the driver is busy */
#define SND_ALIAS 0x00010000L /* name is a registry alias */
#define SND_ALIAS_ID 0x00110000L /* alias is a predefined ID */
#define SND_FILENAME 0x00020000L /* name is file name */
#define SND_RESOURCE 0x00040004L /* name is resource name or atom */
#if (WINVER >= 0x0400)
#define SND_PURGE 0x0040 /* purge non-static events for task */
#define SND_APPLICATION 0x0080 /* look for application specific association */
#endif /* WINVER >= 0x0400 */
#define SND_SENTRY 0x00080000L /* Generate a SoundSentry event with this sound */
#define SND_RING 0x00100000L /* Treat this as a "ring" from a communications app - don't duck me */
#define SND_SYSTEM 0x00200000L /* Treat this as a system sound */