Welcome to CAppSoundsManager, a C++ class which encapsulates the area of "Application
Sounds". These are the sounds which end-users can customize in the Sound tab
of the "Sounds and Audio Devices" control panel applet. The class is based
in part upon the "CSoundMgr" class developed by Paul DiLascia for the
May 2006 edition of the MSDN Magazine
To get you started you should probably read the DiLascia article at
http://download.microsoft.com/download/3/a/7/3a7fa450-1f33-41f7-9e6d-3aa95b5a6aea/MSDNMagazineMay2006en-us.chm
The enclosed zip file contains the
source and a sample VC 2017 dialog based appwizard generated application to show
how to use it.
Features
- Implements a simple easily maintainable MAP based approach to application
sounds.
- Implementations registration and un-registration methods through code
- Unlike the DiLascia implementation which requires the end user to create
logical names as well as registry names in addition to the sound id for each
application sound you want to set up, CAppSoundsManager only requires that you
setup one id and figures out all the other values from this by looking in your
application's resources.
- Whether or not specific sounds should be played from resources if they are
not setup can be individually configured.
- Unlike the DiLascia implementation, the code does not use AfxGetAppName()
for the filename for registration. This approach would cause problems if the
Application name is different than you exe filename.
- Supports the "DispFileName" registry entry for both Application
names and individual sounds. This allows the code to work on MUI builds unlike
the DiLascia implementation. For further information on this and Application
Sound registration details, please see Larry Osterman's WebLog at
https://docs.microsoft.com/en-us/archive/blogs/larryosterman/a-peek-behind-the-beep.
- Works equally well in Unicode as well as ASCII builds.
- Automatically links to the Windows Multimedia library namely "Winmm.lib"
- Include in the download is the AppSoundsManager modules along with a VC
2017 project to build a test app to exercise most of the classes functionality.
- Supports registration of file system based sounds.
- Supports the concept of disabled sounds.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
Updates
v1.09 (24 April 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.08 (4 May 2020)
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.07 (14 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.06 (20 October 2018)
- Updated copyright details
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Removed all code which supported CAPPSOUNDSMANAGER_MFC_EXTENSIONS code
path
v1.05 (2 December 2017)
- Updated copyright details.
- Replaced NULL throughout the codebase with nullptr. This means that the
minimum requirement for the framework is now VC 2010.
- Replaced BOOL throughout the codebase with bool.
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls
v1.04 (24 January 2016)
- Updated copyright details.
- Updated the code to clean compile on VC 2008 - 2015
- The IsRegistered method now use ATL:CRegKey and returns a HRESULT return
value
- The GetCurrentSoundFromRegistry method now uses ATL::CRegKey and returns
a HRESULT return value
- The Register method now uses ATL::CRegKey and returns a HRESULT return value
- The RegisterSound method now uses ATL::CRegKey and returns a HRESULT return
value
- The UnRegister method now uses ATL::CRegKey and returns a HRESULT return
value
- The Initialize method now returns a HRESULT return value
- The CAppSoundsManager::UnRegister method now uses ATL::CRegKey::RecurseDeleteKey
instead of SHDeleteKey.
- Added SAL annotations to all the code.
- Reworked the classes to optionally compile without MFC. By default the class
now use STL classes and idioms but if you define CAPPSOUNDSMANAGER_MFC_EXTENSIONS
the class will revert back to the MFC behaviour.
v1.03 (4 January 2009)
- Updated copyright details.
- Removed VC 6 style AppWizard comments from the code
- Removed unused CAppSoundsManager destructor
- The code has now been updated to support VC 2005 or later only
- Fixed a potential buffer overwrite in CAppSoundsManager::GetCurrentSoundFromRegistry.
This bug was spotted with Code Analysis.
- Code now compiles cleanly using Code Analysis (/analyze)
- The Register method has been completely rewritten and refactored
- The Unregister method now uses SHDeleteKey to ensure key values which have
subkeys are cleanly removed from the registry. The code in this method has also
been refactored.
v1.02 (14 June 2007)
- Updated Register and UnRegister methods to preserve last error code if it
cannot open the "HKCU\AppEvents\EventLabels" registry key.
- Updated copyright details.
v1.0 (22 September 2006)
v1.01 (22 September 2006)
- The existing APP_SOUND macro has been renamed to APP_SOUND_FROM_RESOURCE.
- Now supports registration of file based wave files using the APP_SOUND_FROM_FILE
macro.
- Now supports the concept of a disabled sound, where the sound will only
be played if the end-user configures the value in the control panel through
the new APP_SOUND_DEFAULT_NONE macro.