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 = @"VoiceTime\TIMENOW.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 6) sound = @"VoiceTime\AM0.wav"; else if (DateTime.Now.Hour >= 6 && DateTime.Now.Hour < 12) sound = @"VoiceTime\AM1.wav"; else if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18) sound = @"VoiceTime\PM.wav"; else sound = @"VoiceTime\EM.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); int hours = DateTime.Now.Hour; if (hours > 12) hours = hours - 12; if (hours < 10) sound = @"VoiceTime\T0" + hours + ".wav"; else sound = @"VoiceTime\T" + hours + ".wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); sound = @"VoiceTime\POINT.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); int min = DateTime.Now.Minute; if (min >= 0 && min < 10) sound = @"VoiceTime\T00.wav"; else if (min >= 10 && min < 20) sound = @"VoiceTime\T10.wav"; else if (min >= 20 && min < 30) sound = @"VoiceTime\T20.wav"; else if (min >= 30 && min < 40) sound = @"VoiceTime\T30.wav"; else if (min >= 40 && min < 50) sound = @"VoiceTime\T40.wav"; else if (min >= 50 && min < 60) sound = @"VoiceTime\T50.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); min = min % 10; if (min != 0) { sound = @"VoiceTime\T0" + min + ".wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); } sound = @"VoiceTime\MIN.wav"; sndPlayer = new System.Media.SoundPlayer(sound); sndPlayer.PlaySync(); if (sndPlayer != null) { sndPlayer.Dispose(); sndPlayer = null; } }