PDA

View Full Version : Programmatically cycle sound icon (sound/vibrate/mute)


sbl
02-05-2006, 05:53 AM
When you click on the sound icon, you get the two sliders and three radio buttons. Anyone know how to set those radio buttons through code (C++) so it gets reflected in the icon display (and actually changes the "profile")?. I'd like to change to vibrate/mute/sound at different times using something like alarmToday to run a small app.

Thanks,
sbl

psneddon
04-05-2006, 09:37 PM
I wrote a profiles app in .net and C++ here are some code snippets;

You can change the registry values for the volumes (I cant remember which as I wrote it a long time ago), then you need to call the following to have the values applied.

// ProfilesHelper.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "ProfilesHelper.h"
#include <windows.h>
#include <Soundfile.h>


void WINEXPORT SetSoundMode(int mode)
{
// Initialize an empty SNDFILEINFO structure
SNDFILEINFO sndfile = {0};

if (mode == 0)
sndfile.sstType = SND_SOUNDTYPE_ON;
if (mode == 1)
sndfile.sstType = SND_SOUNDTYPE_VIBRATE;
if (mode == 2)
sndfile.sstType = SND_SOUNDTYPE_NONE;
SndSetSound(SND_EVENT_ALL, &sndfile, false);
void AudioUpdateFromRegistry();
}

void WINEXPORT SetSystemVolume(long volume)
{
waveOutSetVolume(NULL, volume);
void AudioUpdateFromRegistry();
}

NILAVYA
20-05-2006, 12:03 PM
Hi,

I have a similar need of programatically cycling the sound icon to MUTE VIBRATE and normal volume icon. I can do it successfully on Windows Mobile 5.0. I created a sample application with Visual Studio 2005 for WM 5.0 and I am able to set the icons as i want. But when i tried it for PPC2003 I was not able to compile that. Missing SoudFile.h. Can any one help me to find out how to do the same thing on PPC2003 specifically i-mate devices like PDA2 and PDA2K.
Thanks
With Regards,
Bhagat Nirav K.

ather90
15-07-2008, 12:05 PM
i know its a 2 ur old post..but i need help also now

how can i mute sounds using C# in .net 2.0 for WM6

utak3r
08-08-2008, 12:14 PM
Just forget about this header file...
Operate on HKCU\ControlPanel\Notifications\ShellOverrides\Mod e value. It can have 3 states: 0 == normal, 1 == vibrate and 2 == silent. That's all :D
Probably you need to call AudioUpdateFromRegistry function from coredll.dll.

utak3r
08-08-2008, 01:58 PM
Or... another method :)
look at HKCU\ControlPanel\Sounds\RingTone0:Sound, it takes 3 different values:
*none*
*vibrate*
your ringtone name, taken from SavedSound value in the same key.