Results 1 to 6 of 6

Thread: Sounds in the Registry

  1. #1
    BubbaBeans is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Oct 2009
    Location
    Redding, CA
    Posts
    5
    Reputation
    0

    Question Sounds in the Registry

    I know how to access and play the system sounds using vb.net, and I also know that using the registry to save users' settings isn't ideal, however...

    The details of my project are rather long and drawn out, so I'll skip most of them. Basically my program is loaded onto several computers on our network. The entire purpose of this program is to sound various alarms on different dates and times.

    Apparently I am to set up the program so that the different alarm sounds can be configured through Windows' control panel. Ok, that's all fine and good. I can add the program into the appropriate part of the Registry in order to make that happen.

    The problem is reading the the information back. Under the name of the app, I have four different subkeys, each with the name of one of the alarms. Under those keys are two other subkeys, .default and .current.

    How in the world do I get the sound from .current to play?!?! For some weird reason I get nul returned any time I try to read the key that I created.

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,504
    Reputation
    1553

  3. #3
    BubbaBeans is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Oct 2009
    Location
    Redding, CA
    Posts
    5
    Reputation
    0
    This appears to be what I need, but it is used in C/C++, and I'm writing vb.net. How annoying! (And I don't feel like rewriting the entire application in C++. (Been a LONG time since I've done any coding in ANY version of C!)

  4. #4
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,504
    Reputation
    1553
    You don't have to write any C++. You can call Windows API functions, or any exported C/C++ functions for that matter, using the Declare keyword or the DllImport attribute. The technique is called Platform Invoke and there's a web site called PInvoke.net that provides managed declarations of most Windows API functions.

  5. #5
    BubbaBeans is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Oct 2009
    Location
    Redding, CA
    Posts
    5
    Reputation
    0
    Wow, I think I need coffee! I completely forgout about that. Thanks!

  6. #6
    BubbaBeans is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Oct 2009
    Location
    Redding, CA
    Posts
    5
    Reputation
    0

    Cool Further Question

    PlaySound works great for me when I want to play system sounds, but for some reason doesn't seem to find and play the sounds for my program. During the install process, my program adds keys.

    For instance, HKEY_CURRENT_USER\AppEvents\Schemes\Apps\DANotifie r has my four subkeys, 1 Hour, 12 Hours, 24 Hours, After Hours. Each key has a .current and .default key, with the names of the appropriate wav files in place. I can change the sounds through the control panel, so I know the keys are in the right place.

    However, when I use

    PlaySound("1 Hour", IntPtr.Zero, SoundFlags.SND_ASYNC Or _ SoundFlags.SND_ALIAS)

    I get the default Windows sound, rather than the sound I have assigned. What in the world am I missing?!?!?

Tags for this Thread

Bookmarks

Posting Permissions

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