J
juvi
Hello,
Is it possible to get the Vibrate On/Off settings on Windows Mobile
Professional Edition and .net cf?
thx
Is it possible to get the Vibrate On/Off settings on Windows Mobile
Professional Edition and .net cf?
thx
juvi said: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
Achim Bohmann said: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;
}
}
Peter Foot said:The GetCurrentSoundType method is returning the current soundType in the
SoundType argument which is passed by reference.
Peter
--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility
juvi said: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
Achim Bohmann said: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;
}
}
juvi said:Thank you now it works..... but what is the SoundType "File"???
Peter Foot said:The GetCurrentSoundType method is returning the current soundType in the
SoundType argument which is passed by reference.
Peter
--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility
juvi said: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;
}
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.