 |
 |

11-23-2004, 06:02 PM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 8
|
|
XP SP2 Broke my wave playback Need Help
|
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
|
|

11-23-2004, 08:45 PM
|
 |
Junior Contributor
|
|
Join Date: Sep 2004
Location: Seattle
Posts: 211
|
|
|
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.
|
__________________
what was I thinking?!?!
|

11-24-2004, 06:43 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 8
|
|
Quote:
|
Originally Posted by quarque
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.
|
|

11-24-2004, 06:48 AM
|
 |
Martian In Disguise
Retired Moderator * Guru *
|
|
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
|
|
There should be three arguments for the PlaySound API
Code:
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.
Edit:
According to MSDN, sndPlaySound is only maintained for backward compatibility.
|
__________________
The only stupid question is the one that goes un-asked.
|

11-24-2004, 07:17 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 8
|
|
|
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.
|
|

11-24-2004, 09:54 AM
|
 |
Martian In Disguise
Retired Moderator * Guru *
|
|
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
|
|
|
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.
|
__________________
The only stupid question is the one that goes un-asked.
|

11-24-2004, 11:39 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 8
|
|
|
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?
|
|

11-24-2004, 11:42 AM
|
 |
Martian In Disguise
Retired Moderator * Guru *
|
|
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
|
|
|
Yes, VB6 SP6. The only difference would be my laptop has XP Home and not Professional.
|
__________________
The only stupid question is the one that goes un-asked.
|

11-24-2004, 11:57 AM
|
|
Contributor
|
|
Join Date: Oct 2004
Posts: 629
|
|
|
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?
|
|

11-24-2004, 01:11 PM
|
 |
Junior Contributor
|
|
Join Date: Sep 2004
Location: Seattle
Posts: 211
|
|
|
perhaps add some strategic On Error Goto's would show up something that isn't working right (like the path mentioned by JPB).
|
__________________
what was I thinking?!?!
|

11-24-2004, 01:24 PM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 8
|
|
|
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.
|
|

11-24-2004, 01:30 PM
|
 |
Retread
Retired Moderator * Expert *
|
|
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
|
|
|
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.
|
|

11-24-2004, 01:30 PM
|
 |
Martian In Disguise
Retired Moderator * Guru *
|
|
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
|
|
Compiled programs, either linked to or attached are not permitted per this site's Posting Guidelines.
It would be intersting though, if someone else running XP Pro could duplicate your issue.
|
__________________
The only stupid question is the one that goes un-asked.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|