MASM32

MASM安装教程: https://blog.csdn.net/u010486308/article/details/105495848

代码参考:

.model flat, stdcall
option casemap: none

include windows.inc
include kernel32.inc
include user32.inc

includelib kernel32.lib
includelib user32.lib
includelib Winmm.lib

PlaySoundA PROTO,
        pszSound:PTR BYTE, 
        hmod:DWORD, 
        fdwSound:DWORD

.data
file BYTE "nyan-clipped.wav",0

szCaption   db  "Hello", 0
szText      db  "Hello World!", 0

.code
main PROC
     INVOKE PlaySoundA, OFFSET file, NULL, 20001H
     INVOKE MessageBox, NULL, addr szText, addr szCaption, MB_OK
     INVOKE ExitProcess, 0
main ENDP

END main

注意点: 如果需要异步播放,则需要SND_ASYNC标志。 而MASM中直接上与运算后的十六进制位。

即,

#define SND_ASYNC           0x0001 
#define SND_FILENAME    0x00020000L

0x0001 & 0x00020000 => 0x00020001

原文地址:https://www.cnblogs.com/strive-sun/p/14086392.html