Hey guys i'm working on a project at school in a mobile development class. I'm trying to read the current ringer settings on a phone (vibrate, off, on). There is no direct class for this so it has to be done through a platform invoke. I was able to find the code online to set the ringer here:
Code:
using System;
using System.Runtime.InteropServices;
public enum SoundEvent
{
All = 0,
RingLine1,
RingLine2,
KnownCallerLine1,
RoamingLine1,
RingVoip
}
public enum SoundType
{
On = 0,
File,
Vibrate,
None
}
public class clsNotification
{
[DllImport("aygshell.dll", SetLastError = true)]
public static extern uint SndSetSound(SoundEvent seSoundEvent, clsNotification pSoundFileInfo, bool fSuppressUI);
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
private string szPathNameNative;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
private string szDisplayNameNative;
public SoundType SstType;
private string szPathName
{
get
{
return szPathNameNative.Substring(0, szPathNameNative.IndexOf('\0'));
}
set
{
szPathNameNative = value;
}
}
private string szDisplayName
{
get
{
return szDisplayNameNative.Substring(0, szDisplayNameNative.IndexOf('\0'));
}
set
{
szDisplayNameNative = value;
}
}
}
I'm trying to now get the current ringer. aygshell.dll has an API for this called SndGetSound. Unfortunately, I really have no idea on how to set this up. I'm certain it's very similar to the SndSetSound, but I've really tried everything and can't get it to work. Can anyone help me out? Here's a link to SndGetSound from MSDN:
SndGetSound
Thanks for any help guys.