ID: Q89316
The information in this article applies to:
The "More Information" section of this article includes an example of a macro you can use to play a .wav sound file.
NOTE: Microsoft provides macros "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
'These declarations must be on one line.
'Place them above the Sub Main.
Declare Function sndPlaySoundA Lib "winmm" \
(lpszSoundName$, wFlags As Long) As Long
Declare Function GetWindowsDirectoryA Lib \
"Kernel32"(WinDir$, nSize As Long) As Long
Sub MAIN
Windir$ = String$(255, "X")
N = GetWindowsDirectoryA(WinDir$, 255)
N = sndPlaySoundA(WinDir$ + "\tada.wav", 0)
End Sub
'** Calling dynamic-link libraries**
Declare Function sndPlaySound Lib "mmsystem.dll" \
(lpszSoundName$, wFlags As Integer) As Integer
Declare Function GetWindowsDirectory Lib \
"Kernel"(WinDir$, nSize As Integer) As Integer
Sub MAIN
'*Create a variable large enough to store the Windows path.
Windir$ = String$(255, "X")
'*Store the path to the Windows directory in WinDir$ variable.
N = GetWindowsDirectory(WinDir$, 255)
'*Load and Play the sound.
N = sndPlaySound(WinDir$ + "\tada.wav", 0)
End Sub
NOTE: This macro assumes that your computer has a sound driver and
does not check if the driver is loaded.
For more complete information about the sndPlaySound function of the MMSYSTEM.DLL, refer to the "Multimedia Programmer's Reference." This manual is part of the Microsoft Windows operating system version 3.1 Software Development Kit (SDK).
Additional query words: winapi mpc multimedia multi- media personal pc word7 word6
Keywords : kbmacro kbusage kbmacroexample winword word6 winword2 word7 word95
Version : 2.x 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS
Last Reviewed: August 1, 1997