I have a line of code that works when called
from a procedure in Access 2.0 form...
PlaySound("C:\cr\help\Help0018.wav", 0)
I imported what I thought was needed into
A97. However, running it is unsuccessful.
I get an error saying "file mmsystem not found".
I think I've violated some API call protocol.
Here's the PlaySound() function in an A97 standard module:
Function PlaySound(msound, MyParm As Variant)
'================================================= =================
' The following function PlaySound calls the Windows API function
'================================================= =================
On Error GoTo PlaySound_Err
If IsNull(MyParm) Then MyParm = 1
Dim XX%, ErrorMsg As String
' The following COULD be values to 5 of system constants listed below
'0 ' wait until sound is finished playing
'1 ' don't wait for finish
'2 ' play no default sound if sound doesn't exist
'8 ' play sound in an infinite loop (until next apiPlaySound)
'16 ' don't interrupt a playing sound
'
SND_ASYNC These are all API
'XX% = sndPlaySound(msound, 1)' play mmwave sound ' SND_LOOP
system constants
XX% = sndPlaySound(msound, MyParm) ' play mmwave sound '
SND_MEMORY for the second
If XX% = 0 Then GoTo SounDidntPlay '
SND_NODEFAULT parameter to the
'
SND_NOSTOP sndPlaySound func-
PlaySound_Exit: ' SND_SYNC
tion.
Exit Function
'Flags for playing the sound. The following values are defined at
http://www.mentalis.org/apilist/sndPlaySound.shtml
SND_ASYNC: 'The sound is played asynchronously and the function
returns immediately after beginning the sound. To terminate an
asynchronously played sound, call sndPlaySound with lpszSoundName set
to NULL.
SND_LOOP: 'The sound plays repeatedly until sndPlaySound is called
again with the lpszSoundName parameter set to NULL. You must also
specify the SND_ASYNC flag to loop sounds.
SND_MEMORY: 'The parameter specified by lpszSoundName points to an
image of a waveform sound in memory.
SND_NODEFAULT: 'If the sound cannot be found, the function returns
silently without playing the default sound.
SND_NOSTOP: 'If a sound is currently playing, the function immediately
returns FALSE, without playing the requested sound.
SND_SYNC: 'The sound is played synchronously and the function does not
return until the sound ends.
SounDidntPlay:
ErrorMsg = "Sound Didn't Play!" & CRLF
MsgBox ErrorMsg, 48, "Sound Didn't Play - " & MyApp$ & ", rev. " &
MY_VERSION$
GoTo PlaySound_Exit
PlaySound_Err:
Dim r As String, Z As String, Message3 As String
r = "The following unexpected error occurred in Function PlaySound
():"
Z = CRLF & CRLF & Str$(Err) & ": " & Quote & Error$ & Quote
Message3 = r & Z
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume PlaySound_Exit
End Function
And here is my declaration in another global module...
Declare Function sndPlaySound% Lib "mmsystem" (ByVal filename$, ByVal
SND_ASYNC%)
Can anyone help me?