Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sndPlaySound problem 1

Status
Not open for further replies.

TheVampire

Programmer
May 1, 2002
828
US
I'm using the API sndPlaySound to play a wave file constantly ( loop ) until the user clicks a button on screen, or presses any key on the keyboard, at which point I use sndPlaySound with null arguements to stop the sound.

This works fine on my win98 test machine, but the user is on Win NT and complains that the sound does not stop until the machine is rebooted.

Any ideas what is causing this?

Thanks for any help,

Robert
 
are u using vbNull or vbNullString, i can re-create the problem on a 2k box by using vbNull! but using vbNullString works as expected!

good luck

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
To get the best response to a question, please check out FAQ222-2244 first
A General Guide To Excel in VB FAQ222-3383
 
I was just using a blank string instead of the actual vbNull or vbNullString. I'll try your suggestion and see if that fixes the problem.

Robert
 
yup a blank strnig ("") and vbNull both dont seem to stop the sndPlaySound on XP pro and 2k pro, wheras vbNullString does! (not got any 9X machines running so i dont know about them)

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
To get the best response to a question, please check out FAQ222-2244 first
A General Guide To Excel in VB FAQ222-3383
 
I'm pretty confident that this will solve the problem, so I'll go ahead and star you now. :)

Robert
 
vamp you probably already know this but for the benefit of anyone reading this thread in the future.

from MSDN "passing Null Pointers"
arguments can be passed as a null value. Passing a zero-length string ("") does not work, however, as this passes a pointer to a zero-length string. The value of this pointer will not be zero. You instead need to pass an argument with the true value of zero. The easiest way to do this is by using the constant value vbNullString for the appropriate argument:

(and as a semi related aside vbNull = 1)

hope that helps someone!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
To get the best response to a question, please check out FAQ222-2244 first
A General Guide To Excel in VB FAQ222-3383
 
For some odd reason, probably my old age creeping up on me, I'd forgotten about that.... [wink]

Thanks for reminding me!

Robert
 
An update, that this did indeed fix my problem. Thanks again ADoozer!

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top