본문으로 바로가기

알람소리 내기

category Development/C# 2009. 10. 29. 18:25
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Media;

namespace AlamTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("kernel32.dll")]
        public static extern bool Beep(int n, int m);
          
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dteToday = DateTime.Parse(textBox3.Text); //값입력받기
            DateTime dteToday1 = DateTime.Now;                 //오늘날짜
            TimeSpan dte2 = dteToday1 - dteToday;              //오늘 - 입력받은날
            textBox2.Text = dte2.ToString();                   //결과 출력
        }

        private void tmrClock_Tick(object sender, EventArgs e)
        {          
            label5.Text = DateTime.Now.ToShortDateString(); //오늘날짜
            label6.Text = DateTime.Now.ToLongTimeString();  //오늘시간
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime aa = DateTime.Parse(textBox3.Text);         //값입력받기.
            if (aa.ToString() == DateTime.Now.ToString())
            {
                SoundPlayer player = new SoundPlayer(@"C:\Windows\Media\tada.wav"); //소리 재생
                player.PlaySync();
            }
            
        }
    }
}

'Development > C#' 카테고리의 다른 글

MS Chart Control  (2) 2009.11.03
zedgraph  (0) 2009.11.02
Dictionary 제네릭 클래스  (0) 2009.09.24
DataGridView 성능 높이기  (0) 2009.09.15
월중 첫날짜, 마지막날짜 구하기  (0) 2009.09.01