473,700 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\c r\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(msoun d, 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(ms ound, 1)' play mmwave sound ' SND_LOOP
system constants
XX% = sndPlaySound(ms ound, 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 2345
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\syst em

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

Directory of C:\windows\syst em32

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

Directory of C:\windows\syst em32\dllcache

08/18/2001 08:00 AM 68,928 mmsystem.dll
1 File(s) 68,928 bytes
Nov 13 '05 #2
MLH <CR**@NorthStat e.net> wrote in
news:pd******** *************** *********@4ax.c om:
I have a line of code that works when called
from a procedure in Access 2.0 form...

PlaySound("C:\c r\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.

xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxx

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**@NorthStat e.net> wrote in
news:i3******** *************** *********@4ax.c om:
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
1573
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 file. Here's the code hoping to produce an exe for use in another pc: Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long ' ............................................................ Private Sub...
19
15430
by: bballmitch | last post by:
Why won't the following code work? char soundfile2 = "C:/Windows/Media/pinky and the brain.wav"; PlaySound(soundfile2,NULL,SND_FILENAME|SND_SYNC|SND_ASYNC); getchar(); i put libwinmm.a in the parameters and i have all the right headerfiles in there, but it won't work. it says that i must declare SND_FILENAME ,
3
4640
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 szSound, IntPtr hMod, PlaySoundFlags flags ); The file coredll was not found. I changed it to and it now works. What is the best way to handle this? -Harry
4
4509
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 using VC 6.0 for quite some time, I found that I had to add the following lines in order to use the multimedia extensions. In stdafx.h #include <MMSystem.h>
10
2476
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 ..wav files and send them along since PlaySound plays a sound file. One of the options I found in a nice description of PlaySound says that there are a couple of other choices. 1) The sound can be in the registry and actually controlled/selected by the end user.
9
11840
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 application should play a .wav file (not resource) until the user clicks a button to acknowledge the situation. To keep things simple, lets assume there is only one monitor. If I use the old sndPlaySound function, with the code:
3
10637
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 crackling. I'm using a couple WAVs that ship with Windows, and they play fine outside of my app. This code works, but has the random "scratching" problem: private static void PlayResource(string audioRes) { // Get the resource into a stream
3
3157
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 hModule, int dwFlags ); public int SND_ASYNC = 0x0001; // play asynchronously public int SND_LOOP = 0x0008; // loop the sound until next PlaySound
0
1898
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 de be wrong?Here is my code in case someone can help. /* This uses the high level WAVE API PlaySound() to play a WAVE file in memory. I simply open the WAVE file called "nagelas.wav" (ie, in order for this example to work, you should make sure that you have such a WAVE file on your...
0
9206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8963
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7802
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5899
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4400
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2022
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.