From: juvi on
Hello,

Is it possible to get the Vibrate On/Off settings on Windows Mobile
Professional Edition and .net cf?

thx
From: Peter Foot on
On Windows Mobile 5.0 and above the audio mode (on/off/vibrate) is
controlled through SndSetSound and SndGetSound. The special constant
SND_EVENT_ALL is used on Classic/Professional edition as it does not truly
have the concept of profiles like Standard Edition.

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" <juvi(a)discussions.microsoft.com> wrote in message
news:38F8BCED-8A33-48EB-B39D-34BC760E54E2(a)microsoft.com...
> Hello,
>
> Is it possible to get the Vibrate On/Off settings on Windows Mobile
> Professional Edition and .net cf?
>
> thx

From: Achim Bohmann on
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;
}
}
From: juvi on
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" wrote:

> 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;
> }
> }
>
From: Peter Foot on
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" <juvi(a)discussions.microsoft.com> wrote in message
news:E5B471A9-27CA-48D9-877F-1D7CBAE6A938(a)microsoft.com...
> 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" wrote:
>
>> 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;
>> }
>> }
>>