Click here to Skip to main content
15,913,939 members
Articles / Desktop Programming / MFC
Article

Integration with Shell Sound Events

Rate me:
Please Sign up or sign in to vote.
2.78/5 (9 votes)
30 Jan 20041 min read 29.1K   336   12   1
This article describes how to modify entries in registry, in order to register our own sound events.

Introduction

I wanted to register my own and new sound events in shell (see Control Panel, Sounds) for my new application, and I found out there is no API for this. At least, I did not find it. So, I had to discover what should be modified in registry.

Using the code

The code is rather clear, and I used it with success. Works for Unicode too! The idea is that there exists a single class which creates valid entries in registry. Also, this class associates given entry with some unique identifier, and allows to play desired sound on event.

First, valid entries in registry must be created. TSystemSoundMgr::CreateEntriesInRegistry() is used for this. Once registered, we should call TSystemSoundMgr::PlaySoundOnEvent(UINT) and pass event identification.

This class will not play sounds by itself. So, it is up to the programmer to call PlaySoundOnEvent method.

TSystemSoundMgr uses also CRegistryTools. Now I have to apologize, because for sure this class comes from CodeTools, and I do not remember who is the author. It is also probable that I have made some changes to this code (probably about Unicode compilation).

History

It is possible to write more objective code, by using for example map of ID to string, so that in TSystemSoundMgr we would not have to switch by ID, but only search for ID in map. Also method implementation is not consistent, because in one place, I use CRegistryTools, and in the second, I use RegistryAPI directly. Anyway, this is the first version, and I am waiting for comments :)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Business Analyst
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralFrom Microsoft Pin
AndyCLon16-Mar-04 14:19
AndyCLon16-Mar-04 14:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.