Link to home
Start Free TrialLog in
Avatar of Fraser_Admin
Fraser_AdminFlag for Canada

asked on

VB Playing WAV Files

I have the following declaration on a module.
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

I have the following call on a form.  Card.wav is in the same directory as the executable.
PlaySound("card.wav", 0, 0)

On my machine, and on other non-development machines, I can here the wav file fine.  But on a few machines, I am unable to hear it.  Is there another way to play a wav file, or does anyone have a solution to this.  The wav file will play fine in Windows Media Player outside of the VB program.

Thanks



ASKER CERTIFIED SOLUTION
Avatar of Harisha M G
Harisha M G
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fraser_Admin,
sndPlaySound32("Card.wav", 1)
Avatar of Fraser_Admin

ASKER

I tried this first.  It works fine on some machines.  So I'm guessing I'm missing a dll or something.  No clue???
If missing, it should be "winmm.dll".. but since you have media player, generally it will be present.

Look at C:\Windows\System32
A full coded example :

http://www.expressnewsindia.com/c4/ex2/C1193.html

A good example on how to use that function along with all the constants , etc that you can use :

http://rookscape.com/vbgaming/tutB.php

Other then that I will keep myself subcribed to this question to see how it goes :) As I dont want to keep spamming this question !
Avatar of TDSnet
TDSnet

Probably stating the obvious here but have you tested the sound on these machines manually..?
Yes, the wav file plays fine when you play it outside of code on the affected machines.  I don't think it is a problem with my code since it works fine on my development machine and also works on some production machines.  Yes winmm.dll is in c:\winnt\system32 on both the machines that work and those that do not.
Also I am playing it with this flag: &H1
When you say it does not work on those machines that have the winmm.dll, does it give you any errors ? Also are the latest visual basic 6 runtime files on all of the machines or any other files or dependancies for that matter ? Are all the files  that need to be registered are registered using regsvr32 ??

Just some thoughts that you could try out, is all :)
As far as I know everything is fine.  No errors, it just doesn't play.  What files should I be looking for for vb runtime files?
I will check out this and let you know if it makes a difference.
That did not help.
It is very strange.  We have found some wav files will play and some will not.  No clue what the problem could be.
Although my problem is not fixed, I will award mgh_mgharish the points since you had several suggestions.