- Windows sound schemes app driver#
- Windows sound schemes app code#
- Windows sound schemes app windows#
Windows sound schemes app code#
/ the contents of this method with the code editor. / Required method for Designer support - do not modify
Windows sound schemes app windows#
#region Windows Form Designer generated code Protected override void Dispose( bool disposing ) PlaySound(bStrWav, this.Handle, (int) (SND.SND_ASYNC | SND.SND_MEMORY)) StreamWav.Read(bStrWav, 0, (int)streamWav.Length) Create byte arrays for Win32 API call PlaySound() Stream streamWav = thisExe.GetManifestResourceStream("Embedded_Wave_") In this example, the wav file is called mywav.wav. Do this by accessing the wav file's properties. Make sure that you change the Build Action on the project's wav file to "Ebedded Resource". Use reflection assembly to expose embedded wav resources TODO: Add any constructor code after InitializeComponent call Required for Windows Form Designer support Public static extern bool PlaySound(byte data, IntPtr hMod, UInt32 dwFlags) SND_APPLICATION = 0x0080 /* Look for application specific association */ SND_PURGE = 0x0040, /* Purge non-static events for task */ SND_RESOURCE = 0x00040004, /* Name is resource name */ SND_FILENAME = 0x00020000, /* Name is file name */ SND_ALIAS = 0x00010000 ,/* Name is a registry alias */
Windows sound schemes app driver#
SND_NOWAIT = 0x00002000, /* Don't wait on busy driver */ SND_NOSTOP = 0x0010, /* Don't stop any currently playing sound */ SND_LOOP = 0x0008, /* Loop the sound until next PlaySound() called */ SND_MEMORY = 0x0004, /* pszSound pointer to a memory file */ SND_NODEFAULT = 0x0002, /* Silence (default if no sound is found) */ SND_ASYNC = 0x0001, /* Play asynchronously */ SND_SYNC = 0x0000 ,/* Play synchronously (default) */ There are different parameter flags used, defined in a C# Enum. Otherwise we have to send the file path to the method. The registry key, which defines the sound event, is the verb we need to send to PlaySound method. But it also supports playing sound events from registry. The PlaySound method supports the playing of normal wave files stored on the disk. All we have to do is create some registry keys at the right position.
We're also able to add our own sound events to registry. With this knowledge, we can rebuild the control panel view of the system sounds. HKEY_CURRENT_USER\AppEvents\EventLabels\ Description used to display sound event.current Wave file currently used for this sound event. default Wave file defined by the vendor of the application. Because of this it's not very easy to read the sound events in registry, but it's possible. But Windows knows also the Sound Schemes, which can be chosen and altered by the user. We're able to add a new Section for our application. Windows supports Sections, this means every application can create/use it's own section. So the settings can be found under HKEY_CURRENT_USER. The sound events are stored in the registry, this is done by user. Private static extern int PlaySound( String pszSound, int hmod, int falgs)