[英]How to understand PlaySound function API document and implement it in MASM?
I know that putting 20001h in PlaySound function as the last parameter can make the music play synchronously.我知道将 20001h 作为最后一个参数放在 PlaySound 函数中可以使音乐同步播放。 But why is 20001h?
但为什么是 20001h? I also wanted the music played in the background "repeatedly" but I couldn't understand the API document since it does not mention 20001h stands for SND_SYNC nor show what stands for SND_LOOP.
我还希望在后台“重复”播放音乐,但我无法理解 API 文档,因为它没有提到 20001h 代表 SND_SYNC,也没有显示什么代表 SND_LOOP。 Need some enlightenment, big thank!
需要一些启示,非常感谢!
This is my code:这是我的代码:
includelib Winmm.lib
PlaySound PROTO,
pszSound:PTR BYTE,
hmod:DWORD,
fdwSound:DWORD
file BYTE "test.wav",0
SND_SYNC DWORD 0
main proc
mov SND_SYNC, 20001H
INVOKE PlaySound, OFFSET file, NULL, SND_SYNC
.......
I know that putting 20001h in PlaySound function as the last parameter can make the music play synchronously.
我知道将 20001h 作为最后一个参数放在 PlaySound 函数中可以使音乐同步播放。
That is incorrect.这是不正确的。 It plays the file asynchronously .
它异步播放文件。
The last parameter is a bitmask, it can hold multiple flags OR'ed together.最后一个参数是一个位掩码,它可以将多个标志 OR'ed 在一起。
SND_SYNC
is defined as 00000h
(the absence of any other flags), whereas 20001h
is a combination of SND_ASYNC
( 00001h
) OR'ed with SND_FILENAME
( 20000h
). SND_SYNC
定义为00000h
(没有任何其他标志),而20001h
是SND_ASYNC
( 00001h
) 与SND_FILENAME
( 20000h
) 的组合。
SND_LOOP
( 00008h
) can only be used in combination with SND_ASYNC
. SND_LOOP
( 00008h
) 只能与SND_ASYNC
结合使用。
So, to accomplish what you want:所以,要完成你想要的:
I also wanted the music played in the background "repeatedly"
我还想要“重复”在背景中播放的音乐
You need to combine the SND_FILENAME
, SND_ASYNC
, and SND_LOOP
flags.您需要组合
SND_FILENAME
、 SND_ASYNC
和SND_LOOP
标志。 That numeric value is 20009h
.该数值是
20009h
。
Here are all of the flags you can use with PlaySound()
.以下是您可以与
PlaySound()
一起使用的所有标志。 Their meanings are explained in PlaySound
's documentation 1 :它们的含义在
PlaySound
的文档1中进行了解释:
Name![]() |
Value![]() |
---|---|
SND_SYNC ![]() |
0x00000000 ![]() |
SND_ASYNC ![]() |
0x00000001 ![]() |
SND_NODEFAULT ![]() |
0x00000002 ![]() |
SND_MEMORY ![]() |
0x00000004 ![]() |
SND_LOOP ![]() |
0x00000008 ![]() |
SND_NOSTOP ![]() |
0x00000010 ![]() |
SND_PURGE ![]() |
0x00000040 ![]() |
SND_APPLICATION ![]() |
0x00000080 ![]() |
SND_NOWAIT ![]() |
0x00002000 ![]() |
SND_ALIAS ![]() |
0x00010000 ![]() |
SND_ALIAS_ID ![]() |
0x00110000 ![]() |
SND_FILENAME ![]() |
0x00020000 ![]() |
SND_RESOURCE ![]() |
0x00040000 ![]() |
SND_SENTRY ![]() |
0x00080000 ![]() |
SND_RING ![]() |
0x00100000 ![]() |
SND_SYSTEM ![]() |
0x00200000 ![]() |
1 Note: SND_RING
is undocumented, but you can see that SND_ALIAS_ID
is a combination of SND_RING
OR'ed with SND_ALIAS
. 1注意:
SND_RING
未记录,但您可以看到SND_ALIAS_ID
是SND_RING
OR'ed 与SND_ALIAS
的组合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.