private void btnBaoshi_Click(object sender, EventArgs e) { try { System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(PlayTime)); thread.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private static void PlayTime() { System.Media.SoundPlayer sndPlayer; string sound = @"VoiceTimeTIMENOW.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 6) sound = @"VoiceTimeAM0.wav"; else if (DateTime.Now.Hour >= 6 && DateTime.Now.Hour < 12) sound = @"VoiceTimeAM1.wav"; else if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18) sound = @"VoiceTimePM.wav"; else sound = @"VoiceTimeEM.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); int hours = DateTime.Now.Hour; if (hours > 12) hours = hours - 12; if (hours < 10) sound = @"VoiceTimeT0" + hours + ".wav"; else sound = @"VoiceTimeT" + hours + ".wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); sound = @"VoiceTimePOINT.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); int min = DateTime.Now.Minute; if (min >= 0 && min < 10) sound = @"VoiceTimeT00.wav"; else if (min >= 10 && min < 20) sound = @"VoiceTimeT10.wav"; else if (min >= 20 && min < 30) sound = @"VoiceTimeT20.wav"; else if (min >= 30 && min < 40) sound = @"VoiceTimeT30.wav"; else if (min >= 40 && min < 50) sound = @"VoiceTimeT40.wav"; else if (min >= 50 && min < 60) sound = @"VoiceTimeT50.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); min = min % 10; if (min != 0) { sound = @"VoiceTimeT0" + min + ".wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); } sound = @"VoiceTimeMIN.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); if (sndPlayer != null) { sndPlayer.Dispose(); sndPlayer = null; } }