地老天荒的意思是什么:编程高手请进!~~~~

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 17:10:30
谁能告诉我,在VB6.0中怎么用代码控制计算机的关机.比如说,一个VB编的生成的一个exe文件,双击后,开始到计时,时间为十秒,十秒后计算机便关机了.请个问高手指教,这要怎么实现啊?

Private Sub Command1_Click()
aa = Text1.Text
End Sub

Private Sub Command2_Click()
Text1.Text = ""
End Sub

Private Sub Form_Load()
aa = Format("23:59:59")
End Sub

Private Sub Timer1_Timer()

If Format(Time$, "hh:mm:ss") > Format(aa, "hh:mm:ss") Then
Shell ("shutdown.exe /s /t 00")
End If
End Sub
还有这个

Public aa As String
Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Command1_Click()
aa = Text1.Text
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
If Format(Time, "hh:mm:ss") > Format(aa, "hh:mm:ss") Then
'Shell ("shutdown.exe /s /t 01")
MsgBox "时间到"
Timer1.Enabled = False
End If
End Sub

为什么不直接给shutdown加参数让10秒后关机???

Private Sub Command1_Click()
shell("shutdown -s -t " && text1.text && " -c " && text2.text)
End Sub
'text1.text是时间 text2.text是关机警告内容。