请教VB程序

来源:百度知道 编辑:UC知道 时间:2024/05/24 12:44:16
我想在每天某个特定的时间,播放某个音乐文件(最好是后台播放),请问该怎么编写?
那代码是怎么样的?要运行的话直接放到开机运行不就行了

代码如下。
====================
Option Explicit
Private Const T As Date = #7:33:00 PM# '你设定的时间
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Private Sub Form_Load()
Timer1.Interval = 60000
Timer1.Enabled = True
Hide '后台运行
End Sub

Private Sub Timer1_Timer()
If Hour(T) = Hour(Now) Then
If Minute(T) = Minute(Now) Then sndPlaySound "d:\1.wav", 0 '你的文件名
End If
End Sub

很简单啊。不过首先你的程序要运行起来才行。

不用编,现在的许多定时关机程序都有此功能的!

可以的,和自动提醒功能一样的

将窗体hide,用timer定时检查系统时间,到点用mciSendString函数播放
然后在注册表里加启动项
mciSendString "open C:\a.mp3 alias mc", 0, 0, 0

app.taskvisible = false