Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > XP SP2 Broke my wave playback Need Help


Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2004, 06:02 PM
Wireman Wireman is offline
Newcomer
 
Join Date: Sep 2003
Posts: 8
Default 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
Reply With Quote
  #2  
Old 11-23-2004, 08:45 PM
quarque's Avatar
quarque quarque is offline
Junior Contributor
 
Join Date: Sep 2004
Location: Seattle
Posts: 211
Default

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?!?!
Reply With Quote
  #3  
Old 11-24-2004, 06:43 AM
Wireman Wireman is offline
Newcomer
 
Join Date: Sep 2003
Posts: 8
Default

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.
Reply With Quote
  #4  
Old 11-24-2004, 06:48 AM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

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.
Reply With Quote
  #5  
Old 11-24-2004, 07:17 AM
Wireman Wireman is offline
Newcomer
 
Join Date: Sep 2003
Posts: 8
Default

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.
Reply With Quote
  #6  
Old 11-24-2004, 09:54 AM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

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.
Reply With Quote
  #7  
Old 11-24-2004, 11:39 AM
Wireman Wireman is offline
Newcomer
 
Join Date: Sep 2003
Posts: 8
Default

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?
Reply With Quote
  #8  
Old 11-24-2004, 11:42 AM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

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.
Reply With Quote
  #9  
Old 11-24-2004, 11:57 AM
JPB JPB is offline
Contributor
 
Join Date: Oct 2004
Posts: 629
Default

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?
Reply With Quote
  #10  
Old 11-24-2004, 01:11 PM
quarque's Avatar
quarque quarque is offline
Junior Contributor
 
Join Date: Sep 2004
Location: Seattle
Posts: 211
Default

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?!?!
Reply With Quote
  #11  
Old 11-24-2004, 01:24 PM
Wireman Wireman is offline
Newcomer
 
Join Date: Sep 2003
Posts: 8
Default

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.
Reply With Quote
  #12  
Old 11-24-2004, 01:30 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

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.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #13  
Old 11-24-2004, 01:30 PM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->