Help calling an unmanged function on Windows Mobile

  • Thread starter Thread starter Paul Sneddon
  • Start date Start date
P

Paul Sneddon

Hi,

I'm using VS.NET 2005 RC to create Windows Mobile apps. I'm trying to call
the following shell function which is new on Windows Mobile 5.

SNDGETSND
http://msdn.microsoft.com/library/d...en-us/mobilesdk5/html/wce51lrfSndSetSound.asp

I basically just need to be able to get the device ringer mode (e.g. On Off
Vibrate) this seems the way to do it in WM5.

I can set up the declaration (dll import, structs, pointers etc) but when I
call it I get a "Not Supported" exception. I tried setting various unmanged
directives on the structs and parameters which stops the exception but the
call doesnt have a return value and does not seem to work, but I dont really
know what I'm doing when it comes to calling unmanged code.

Could someone proide we will a basic working example for declaring and
calling this function and I should be able to work out everything else from
there. I got that frustrated that I deleted my example code..

Paul
 
Hi,

I get it to kind of work but everytime I call the function, no mater what
enum value I pass it always sets the sound to on???

[DllImport("aygshell.dll", CharSet = CharSet.Unicode)]

public static extern Int32 SndSetSound

(SND_EVENT seSoundEvent,ref SNDFILEINFO pSoundFileInfo, bool fSuppressUI);

[StructLayout(LayoutKind.Sequential)]

public struct SNDFILEINFO

{

[MarshalAs(UnmanagedType.LPTStr, SizeConst = 260)]

public string szPathName;

[MarshalAs(UnmanagedType.LPTStr, SizeConst = 260)]

public string szDisplayName;

public SND_SOUNDTYPE sstType;

}


public enum SND_SOUNDTYPE

{

SND_SOUNDTYPE_ON = 0x0001,

SND_SOUNDTYPE_FILE = 0x0002,

SND_SOUNDTYPE_VIBRATE = 0x0004,

SND_SOUNDTYPE_NONE = 0x0008,

SND_SOUNDTYPE_LAST = SND_SOUNDTYPE_NONE

}

public enum SND_EVENT

{

SND_EVENT_ALL,

SND_EVENT_RINGTONELINE1,

SND_EVENT_RINGTONELINE2,

SND_EVENT_LAST = SND_EVENT_RINGTONELINE2

}



Paul
 
Hi,

I think you will get a better answer in the CF
group:microsoft.public.dotnet.framework.compactframework


cheers,
 
Back
Top