Results 1 to 2 of 2

Thread: Checking Registry to play sounds?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    3

    Checking Registry to play sounds?

    OK. I'm designing a little chat program for fun and for the heck of it. It has sounds that you can play, as well as an options form. If you click on the "Sounds On!" options and then my "Apply" command then it will set a registry key named "Sounds" with a value of "1", or if you do "Sounds Off!" then it will set that key to "0". Now here's my dillemma:

    When you click on one of the Sound commands, for instance the slap one, it has an If Then statement. I want it to check that if the registry key named "Sounds" has a value of "1" then go ahead and play the sound...if it's not "1" then don't do anything. Right now my code looks something like this...

    cmdSlap
    If GetSetting("PChat", _
    "Options", "Sounds") = 1 Then
    playsound = sndPlaySound("sounds\slap.wav", 1)
    End If
    End Sub

    There is more code in there but it's irrelevant. Just one to set focus to the message box after it's done...and that's after the End If. Now I know that the

    If GetSetting("PChat", _
    "Options", "Sounds") = 1 Then
    blah blah blah
    End If

    works, becuase in my options form it accesses the registry and finds out what the values are so your options are saved and you do not have to reapply them. Like...

    Private Sub Form_Load()
    If GetSetting("PChat", _
    "Options", "Sounds") = 1 Then
    Option1 = True
    Else
    Option2 = True
    End If
    If GetSetting("PChat", _
    "Options", "WebAllow") = 1 Then
    Check1.Value = 1
    Else
    Check1.Value = 0
    End If
    End Sub

    That's in my options form...and it does work. So why won't it work for the sounds and play my sound when I want it to, lol. I made sure by going into regedit and made sure that the Key was set to "1". I just don't get it. Well, can anyone shed some light on this?

    Oh yeah and to play my sounds here's the code at the top...

    Private Declare Function mciSendString Lib "winmm.dll" Alias _
    "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
    lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
    hwndCallback As Long) As Long
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

    I don't get it! lol

    Snadman
    [email protected]

  2. #2
    Megatron
    Guest
    Is the registry value a string? If so you need to do a string comparison instead of a numeric comparison e.g.
    Code:
    If GetSetting("PChat", _ 
    "Options", "Sounds") = "1" Then...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width