Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > General forums > Development
User Name
Password
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-24-2008, 08:09 PM   #1 (permalink)
PigBenis
duh
 
PigBenis's Avatar
 
Join Date: May 2002
Location: Boiler Up
Posts: 517
-8 Internets
Send a message via AIM to PigBenis
CF .net p/invoke reading the phones current ringer

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.
PigBenis is offline   Reply With Quote
Old 04-24-2008, 10:09 PM   #2 (permalink)
Jaytee Bushwacker
FoH Member with a rod in his pants
 
Jaytee Bushwacker's Avatar
 
Join Date: Jan 2002
Location: Forest, MS
Posts: 233
-1 Internets
I've been working on WMI stuff and for that you have to create a base object and then do a get parameters function in order to pass args to the method you want to invoke.

Sounds like that msdn article does something along those lines. You have to query for the seSoundEvent (whatever the ringer would be called) and pass in a pointer to an object (pSoundFileInfo) you already created. It then populates the object with the filename.

I don't know how you would invoke the method SndGetSound method from that msdn article though. I haven't done any mobile phone or CF.NET work though so I may be totally in left field.

You have googled for examples of the method right?
__________________
Jaytee Bushwacker is offline   Reply With Quote
Old 04-25-2008, 06:47 AM   #3 (permalink)
PigBenis
duh
 
PigBenis's Avatar
 
Join Date: May 2002
Location: Boiler Up
Posts: 517
-8 Internets
Send a message via AIM to PigBenis
Quote:
Originally Posted by Jaytee Bushwacker View Post
I've been working on WMI stuff and for that you have to create a base object and then do a get parameters function in order to pass args to the method you want to invoke.

Sounds like that msdn article does something along those lines. You have to query for the seSoundEvent (whatever the ringer would be called) and pass in a pointer to an object (pSoundFileInfo) you already created. It then populates the object with the filename.

I don't know how you would invoke the method SndGetSound method from that msdn article though. I haven't done any mobile phone or CF.NET work though so I may be totally in left field.

You have googled for examples of the method right?
Yeah there are a bunch of examples on the SndSetSound method, but none on the GetSound. What you described is kind of what I have tried, however it's not working for some reason, and debugging debugging p/invokes is like taking a shot in the dark. This is what i'm sitting at now.

Code:
clsNotification blah = new clsNotification(); uint rettVal = clsNotification.SndGetSound(SoundEvent.All, blah);
Here is how I setup the SndGetSound method:
Code:
public static extern uint SndGetSound(SoundEvent seSoundEvent, clsNotification pSoundFileInfo);
It will execute, but always comes back with the value ringer on.
PigBenis is offline   Reply With Quote
Old 04-25-2008, 02:19 PM   #4 (permalink)
PigBenis
duh
 
PigBenis's Avatar
 
Join Date: May 2002
Location: Boiler Up
Posts: 517
-8 Internets
Send a message via AIM to PigBenis
Got it btw, had to make a structure...
Code:
using System; using System.Runtime.InteropServices; public class clsNotification { private enum SoundEvent { All = 0, RingLine1, RingLine2, KnownCallerLine1, RoamingLine1, RingVoip } private 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 int SetRingerVibrate() { SNDFILEINFO sfi = new SNDFILEINFO(); sfi.SstType = SoundType.Vibrate; uint ret = SndSetSound(SoundEvent.All, ref sfi, true); if (ret != 0) { return 1; } return 0; } public int SetRingerOff() { SNDFILEINFO sfi = new SNDFILEINFO(); sfi.SstType = SoundType.None; uint ret = SndSetSound(SoundEvent.All, ref sfi, true); if(ret != 0) { return 1; } return 0; } public int SetRingerOn() { SNDFILEINFO sfi = new SNDFILEINFO(); sfi.SstType = SoundType.On; uint ret = SndSetSound(SoundEvent.All, ref sfi, true); if(ret != 0) { return 1; } return 0; } private SNDFILEINFO mOldSoundFileInfo = new SNDFILEINFO(); public int SaveSound() { uint ret = SndGetSound(SoundEvent.All, ref mOldSoundFileInfo); if(ret != 0) { return 1; } return 0; } public int RestoreSound() { uint ret = SndSetSound(SoundEvent.All, ref mOldSoundFileInfo, true); if(ret != 0) { return 1; } return 0; } }
PigBenis is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
uberguilds network



All times are GMT -7. The time now is 02:44 PM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6