I remember a while ago that I needed to enable the vibration for a client's application. So I googled a bit and found the similar codes like below... And today, I found some people are looking for this solution on MSDN... So I decided to post it in C# and hope it will give some people a heads up...



       /// 
        /// This function plays the specified vibration.
        /// 
        /// Must be 0
        /// Must be NULL
        /// A Boolean value that indicates whether the song 
        /// should be repeated. If this parameter is equal to TRUE, it will refer to dwTimeout 
        /// to determine how long the vibration song should play.
        /// Must be INFINITE
        /// 
        /// This API is not supported by Windows Mobile 6 Professional.
        [DllImport("aygshell.dll", EntryPoint = "Vibrate")]
        private static extern int VibrateStart(int cvn, IntPtr rgvn, bool fRepeat, uint dwTimeout);

        /// 
        /// Stops all current vibration songs.
        /// 
        /// 
        /// 
        /// This API not supported by Windows Mobile 6 Professional.
        /// 
        [DllImport("aygshell.dll")]
        private static extern int VibrateStop();

        private const uint INFINITE = 0xffffffff;

        /// 
        /// Start the mobile vibration.
        /// This is not supported by Windows Mobile 6 Professional.
        /// 
        /// 
        public static int StartVibrate()
        {
            return VibrateStart(0, IntPtr.Zero, true, INFINITE);
        }

        /// 
        /// Stops all current vibration.
        /// This is not supported by Windows Mobile 6 Professional.
        /// 
        public static void StopVibrate()
        {
            VibrateStop();
        }