472,331 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

Trying to use Playsound in A97...

MLH
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?
Nov 13 '05 #1
5 2259
MLH
I have found the dll file in several places. So, I'm sure I
have it. There must be some other reason for A97 to
report that it cannot be found???

Directory of C:\windows\system

08/18/2001 08:00 AM 68,928 MMSYSTEM.DLL
1 File(s) 68,928 bytes

Directory of C:\windows\system32

08/18/2001 08:00 AM 68,928 mmsystem.dll
1 File(s) 68,928 bytes

Directory of C:\windows\system32\dllcache

08/18/2001 08:00 AM 68,928 mmsystem.dll
1 File(s) 68,928 bytes
Nov 13 '05 #2
MLH <CR**@NorthState.net> wrote in
news:pd********************************@4ax.com:
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)


Access 2.0 was 16-bit, so any APIs you use would be 16-bit APIs. You
can't (well, shouldn't) use those in A97, but use the 32-bit API
calls instead. This should give you what you want:

http://www.mvps.org/access/api/api0011.htm

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3
MLH
I thought the declare statement I am using was a 32-bit API procedure.
But, checking the site you directed me to, the code looks quite a
bit different. Will give it a try. Thanks, David.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Access 2.0 was 16-bit, so any APIs you use would be 16-bit APIs. You
can't (well, shouldn't) use those in A97, but use the 32-bit API
calls instead. This should give you what you want:

http://www.mvps.org/access/api/api0011.htm


Nov 13 '05 #4
MLH <CR**@NorthState.net> wrote in
news:i3********************************@4ax.com:
Access 2.0 was 16-bit, so any APIs you use would be 16-bit APIs.
You can't (well, shouldn't) use those in A97, but use the 32-bit
API calls instead. This should give you what you want:

http://www.mvps.org/access/api/api0011.htm


I thought the declare statement I am using was a 32-bit API
procedure. But, checking the site you directed me to, the code
looks quite a bit different. Will give it a try. Thanks, David.


If it worked in Access 2, it couldn't possibly be 32-bit.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5
MLH
Touche. Little more brain-death catching up with me in
where that little piece of info must-a-been stored. Thx.

If it worked in Access 2, it couldn't possibly be 32-bit.


Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: steve marchant | last post by:
You can see I'm quite new to this. VB5. Trying to play a sound using embedding. So I put an OLE control in the form and created an object from...
19
by: bballmitch | last post by:
Why won't the following code work? char soundfile2 = "C:/Windows/Media/pinky and the brain.wav"; ...
3
by: Harry J. Smith | last post by:
I added some sounds to my application, but the example in the msdn Library did not work. It had: public static extern bool PlaySound( string...
4
by: rcattral | last post by:
Has anybody been using the PlaySound() function to play WAV files from within a DLL? Here is what I normally do. Since upgrading to 7.1 NET after...
10
by: Ot | last post by:
I found information on PlaySound. I implemented it in my program and it works just dandy. The only little problem is that I have to package the...
9
by: Andy | last post by:
Hi, I have an application that has several forms. Each form acts as a monitor of a gateway system. If the gateway appears to be dead, the...
3
by: Jared | last post by:
I'm using the first code sample below to play WAV files stored as embedded resources. For some reason I *occasionally* get scratching and...
3
by: tamarindm | last post by:
I need to play a .wav file over and over again. I am using the following code. private static extern bool PlaySound( string lpszName, int...
0
by: poppy | last post by:
I tried to play a wav file with function Playsound() but it played only the first seconds of the song.I would like to play whole the song.What might...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.