Thank you for your reply, but do not get your class work:
How can I use this? If I understand it correctly then I can set or get
the
current "profile" with this class on classic/professional.
How can I get the current soundType??
thx
:
Hi Juvi,
as far as I understand, you are searching for the same methods I was
searching some weeks ago.
use the following class as your helper class.
hth,
Achim
public static class RingerNotification {
private static SNDFILEINFO mOldSoundFileInfo = new
SNDFILEINFO();
private enum SoundEvent {
All = 0,
RingLine1,
RingLine2,
KnownCallerLine1,
RoamingLine1,
RingVoip
}
public enum SoundType {
On = 0,
File = 1,
Vibrate = 2,
None = 3
}
private struct SNDFILEINFO {
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string szPathNameNative;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string szDisplayNameNative;
public SoundType SstType;
}
[DllImport( "aygshell.dll", SetLastError = true )]
private static extern uint SndSetSound( SoundEvent
seSoundEvent, ref SNDFILEINFO pSoundFileInfo, bool fSuppressUI );
[DllImport( "aygshell.dll", SetLastError = true )]
private static extern uint SndGetSound( SoundEvent
seSoundEvent, ref SNDFILEINFO pSoundFileInfo );
public static bool SetRingerVibrate() {
SNDFILEINFO sfi = new SNDFILEINFO();
sfi.SstType = SoundType.Vibrate;
uint ret = SndSetSound( SoundEvent.All, ref sfi, true );
if( ret != 0 ) {
return false;
}
return true;
}
public static bool SetRingerOff() {
SNDFILEINFO sfi = new SNDFILEINFO();
sfi.SstType = SoundType.None;
uint ret = SndSetSound( SoundEvent.All, ref sfi, true );
if( ret != 0 ) {
return false;
}
return true;
}
public static bool SetRingerOn() {
SNDFILEINFO sfi = new SNDFILEINFO();
sfi.SstType = SoundType.On;
uint ret = SndSetSound( SoundEvent.All, ref sfi, true );
if( ret != 0 ) {
return false;
}
return true;
}
public static bool SaveSound() {
uint ret = SndGetSound( SoundEvent.All, ref
mOldSoundFileInfo );
if( ret != 0 ) {
return false;
}
return true;
}
public static bool RestoreSound() {
uint ret = SndSetSound( SoundEvent.All, ref
mOldSoundFileInfo, true );
if( ret != 0 ) {
return false;
}
return true;
}
public static bool GetCurrentSoundType( ref SoundType
SoundType ) {
SNDFILEINFO sfi = new SNDFILEINFO();
uint ret = SndGetSound( SoundEvent.All, ref sfi );
SoundType = sfi.SstType;
if( ret != 0 ) {
return false;
}
return true;
}
}