XP SP2 Broke my wave playback Need Help

Wireman
11-23-2004, 06:02 PM
I have a program I wrote in VB6 and am using the following code to do wave playback and it works until I compile it into an .exe. Then the wave playback does not work any more. It all worked until I installed SP2 for winXP. Does anyone have any suggestion to fix the code.
I have downloaded multiple examples and they all do the same thing (work until compiled to a .exe).
The code I am using is:

Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

SndPlaySound "mywavefile.wav", 0

quarque
11-23-2004, 08:45 PM
one thing to look for is more than one version of winmm.lib on your system. it could be the compiler is using a different file than when you run in the IDE. If this is the case you need to add a complete pathname in the Declare so it knows which one to use. Are you runing this exe on the same computer? If not, you may need to use the the P&D wizard to deploy it with all required files.

Wireman
11-24-2004, 06:43 AM
one thing to look for is more than one version of winmm.lib on your system. it could be the compiler is using a different file than when you run in the IDE. If this is the case you need to add a complete pathname in the Declare so it knows which one to use. Are you runing this exe on the same computer? If not, you may need to use the the P&D wizard to deploy it with all required files.

Thanks, for the reply. Unfortunately it did not help.
I did add the full path "C:\windows\system32\winmm.dll" to my program and it still only played sound while running it in the IDE. When I compile it to a .exe the sound still does not work. I am running the compiled program on the same machine that VB 6 is on and have tried it on 2 other machines running SP2 and have the same results with them all.
I am not to the point of the P&D wizard at this time since it needs to work before I redistribute it.
This is strange and any help would be appreciated.

00100b
11-24-2004, 06:48 AM
There should be three arguments for the PlaySound API

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

See the PlaySound description and the example linked to at the bottom of the linked page.

This API should be used over the sndPlaySound API call.


According to MSDN, sndPlaySound (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_sndplaysound.asp) is only maintained for backward compatibility.

Wireman
11-24-2004, 07:17 AM
Copied your line exactly into my program.
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Line used to call the wave file.
retVal = PlaySound("MyFile.wav", 0&, &H20000)

Still have the same results. Plays under the IDE but no go when compiled to a .exe.
I see the challange is on. Those with SP2 installed give it a try and lets see if it is the same with yours.

00100b
11-24-2004, 09:54 AM
Sorry, but on my SP2ed XP, the sound plays both within the IDE as a compiled EXE.

At first, I thought that your problem may be because of how you are passing NULL to the hModule parameter. Every example that I've looked at uses ByVal 0&, but I've run the test using both methods and it plays just fine.

Wireman
11-24-2004, 11:39 AM
Now I am really confused. I have 3 machines all set up the same with XP Prof. with SP2, Visual Basic 6 with all the service packs installed up to VBSP6 and I get the same result on all three computers. They all worked fine until I did the SP2 installation.
The sound plays in the IDE but not when compiled to a .exe.
00100b are you using VB 6?

00100b
11-24-2004, 11:42 AM
Yes, VB6 SP6. The only difference would be my laptop has XP Home and not Professional.

JPB
11-24-2004, 11:57 AM
This may be a stupid question, but is your WAV file located in the same folder as your compiled EXE? Maybe you should fully qualify the path of your wav file in the PlaySound call?

quarque
11-24-2004, 01:11 PM
perhaps add some strategic On Error Goto's would show up something that isn't working right (like the path mentioned by JPB).

Wireman
11-24-2004, 01:24 PM
The wave is located where the compiled file is located and I have tried putting in the whole path to the wave file, but I keep getting the same results.
The wave will play while running it in the VB IDE, but not after it is compiled to an exe. Everything worked fine until I upgraded to SP2.
I offer the program as a shareware program and if it is ok I will include a link to download it. I am not trying to promote it or anything like that. It just has me confused that after installing SP2 the sound quit working, so I started working on it and when I ran it under the IDE the sound worked, so I knew it was in SP2 but I seem to be the only one experiencing the problem. But I am really confused since it does it on all my machines. All are running XP Pro w/SP2.
Maybe someone out there is running XP Pro w/SP2 and VB6 with all the SP's installed and can duplicate my problem and maybe can figure out some answers. It may be something MS needs to look at?????

Remember if it ain't broke don't fix it.

MikeJ
11-24-2004, 01:30 PM
If it's in your application's path, shouldn't you be doing:
retVal = PlaySound(App.Path & "\MyFile.wav", 0&, &H20000)

I find it hard to believe that it's SP2 that's causing all of this, unless your soundcard's
drivers are not compatible with it (which again I find hard to believe). Do other sounds
(from other programs) work properly? It might be a soundcard compatibility issue, not
because of VB.

00100b
11-24-2004, 01:30 PM
Compiled programs, either linked to or attached are not permitted per this site's ...

It would be intersting though, if someone else running XP Pro could duplicate your issue.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum