试试看这个 新建一个工程,将在窗体上增加一个Timer控件,并将其执行间隔设置为60000 dim count as integer private sub form_load() on error resume next open "count.txt" for input as #1 input #1,cout close #1 me.show me.hide end subprivate sub timer1_timer() cout=cout+1 if cout>=150 then msgbox "Time is over 150m...": shell "shutdown.exe -s" ' when you system is winXP,shutdown you computer end if open "count.txt" for output as #1 print #1,cout close #1 end sub
最上一行应该是:dim cout as integer 然后你将该程序编译后加入到系统的“启动”项中。
Option Explicit Dim I As Integer Dim intmin As Integer Private Sub Command1_Click() intmin = Text1.Text If intmin > 300 Then MsgBox "你设置的时间太长,系统不允许!" intmin = 150 End If Form1.HideEnd SubPrivate Sub Form_Load() On Error Resume Next Open "d:\usepc.txt" For Input As #1 Input #1, I Close #1 If I = 0 Then Me.Show Else Me.Hide End IfEnd SubPrivate Sub Timer1_Timer() I = I + 1 If I >= intmin Then MsgBox "Time is over " & intmin & "150m...":
Shell "shutdown.exe -s" ' when you system is winXP,shutdown you computer End If Open "count.txt" For Output As #1 Print #1, I Close #1End Sub 但是如果写入注册表是不是好一点,而且这样好象只要有一次,以后接开不料机了,
新建一个工程,将在窗体上增加一个Timer控件,并将其执行间隔设置为60000
dim count as integer
private sub form_load()
on error resume next
open "count.txt" for input as #1
input #1,cout
close #1
me.show
me.hide
end subprivate sub timer1_timer()
cout=cout+1
if cout>=150 then
msgbox "Time is over 150m...":
shell "shutdown.exe -s" ' when you system is winXP,shutdown you computer
end if
open "count.txt" for output as #1
print #1,cout
close #1
end sub
然后你将该程序编译后加入到系统的“启动”项中。
AAAAAAAAAA
假如别人用DOS怎么办?VB程序只能在Win32平台下运行
Dim I As Integer
Dim intmin As Integer
Private Sub Command1_Click()
intmin = Text1.Text
If intmin > 300 Then
MsgBox "你设置的时间太长,系统不允许!"
intmin = 150
End If
Form1.HideEnd SubPrivate Sub Form_Load()
On Error Resume Next
Open "d:\usepc.txt" For Input As #1
Input #1, I
Close #1
If I = 0 Then
Me.Show Else
Me.Hide
End IfEnd SubPrivate Sub Timer1_Timer()
I = I + 1
If I >= intmin Then
MsgBox "Time is over " & intmin & "150m...":
Shell "shutdown.exe -s" ' when you system is winXP,shutdown you computer
End If
Open "count.txt" For Output As #1
Print #1, I
Close #1End Sub
但是如果写入注册表是不是好一点,而且这样好象只要有一次,以后接开不料机了,
为什么?因为你用的是Windows
别人可以进DOS Kill你的EXE,就算你的程序再NB也没办法
现在光盘版的Windows到处都是,只要能够CD-ROM启动还管你是什么操作系统