Dear All,
I am developing a program like an alarm, which will play a sound at a specified time, but if the device is in standby mode, i can't play the sound, so how could I play sound while it is in standby mode.
note: i am using VS.net 2005 C#
Dear All,
I am developing a program like an alarm, which will play a sound at a specified time, but if the device is in standby mode, i can't play the sound, so how could I play sound while it is in standby mode.
note: i am using VS.net 2005 C#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hoang Nguyen VanPosted Apr 6, 2006, 9:44 PM
Hi all,
I have doing it last nigh and i want to share it with you!
I think, you should use Invoke method to got some functions in API or MFC to play sound.
You can use some prototype like this to get some functions. I mean playsound function to play a song with .wav
using System;
using System.Runtime.InteropServices;
namespace ClassSound
{
///
/// Summary description for InvokeSound.
///
public class InvokeSound
{
public InvokeSound()
{
}
[DllImport("coredll", EntryPoint="PlaySound", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.Winapi,SetLastError=false)]
public static extern bool ExplicitSyntax_PlaySound( string szSound, IntPtr hMod, int flags );
//This method uses the default values for all the arguments of the DllImport attribute instead
//of explicitly providing values for them like the ExplicitSyntax_PlaySound procedure above.
[DllImport("coredll")]
public static extern bool PlaySound (string szSound, IntPtr hMod, int flags);
[DllImport("coredll")]
public static extern IntPtr MCIWndCreate(IntPtr hwndParent, IntPtr hInstance, int dwStyle, string szFile);
[DllImport("coredll")]
public static extern long MCIWndClose(IntPtr hwnd);
[DllImport("coredll")]
public static extern void MCIWndDestroy(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndEnd(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndHome(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndPause(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndPlay(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndResume(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndStop(IntPtr hwnd);
[DllImport("coredll")]
public static extern long MCIWndSetVolume(IntPtr hwnd, int iVol);
[DllImport("coredll")]
public static extern void MCIWndSetRepeat(IntPtr hwnd, bool f);
[DllImport("coredll")]
public static extern IntPtr GetSafeHwnd();
[DllImport("coredll")]
public static extern IntPtr AfxGetInstanceHandle();
}
}
after that you can use these function as well as API in win32
good luck