Kuckucks Uhr in C#

using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
 
namespace Uhr
{
    public partial class Form1 : Form
    {
        [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]
        protected static extern int mciSendString
        (string mciCommand,
        StringBuilder returnValue,
        int returnLength,
        IntPtr callback);
        [DllImport("kernel32.dll")]
        public static extern bool Beep(int frequency, int duration);
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < DateTime.Now.Hour; i++)
            {
                mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
                Beep(1000, 1000);
                mciSendString("set cdaudio door closed", null, 0, IntPtr.Zero);
            }
        }
 
    }
}
This entry was posted in .Net, Code, Cool. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>