VB写恶搞程序
我想要的是重启原理,是如何从点击按钮,然后到重启间的过程
我想要的是重启原理,是如何从点击按钮,然后到重启间的过程
答案:块中加入如下代码:Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
'上面声明常数 和 API函数
Function exitproc(ByVal exefile As String) As Boolean
exitproc = False '先将该函数过程赋值为假
Dim hSnapShot As Long, uProcess As PROCESSENTRY32
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&) '给系统进程创建快照 调用成功 则返回快照的句柄 调用失败 返回INVAID_HANDLE_VALUE
uProcess.dwSize = Len(uProcess)
r = Process32First(hSnapShot, uProcess) '初始遍历进程
Do While r
If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = exefile Then 'left截取null前的字符~也就是进程列表~再判断是否有qq.exe
exitproc = True '该函数过程为真 即有此进程
Exit Do '退出循环
End If
r = Process32Next(hSnapShot, uProcess) '遍历下一个进程
Loop
End Function窗体代码如下 一个timer控件 一个按钮(可要可不要)
Private Sub Command1_Click()
Timer1.Enabled = False '停止监控
End SubPrivate Sub Form_Load()
Timer1.Interval = 1000
End SubPrivate Sub Timer1_Timer()
If exitproc("QQ.exe") Then '检测QQ.exe进程是否存在
Else
x = MsgBox("15秒后关闭计算机", vbYesNo, "警告") '弹出对话框
Timer1.Enabled = False '先将timer控件暂停监视
If x = vbYes Then '如果点击对话框“是”按钮 则执行关机
Shell "cmd /c shutdown -s -t 15", 0
Else
Timer1.Enabled = True '如果点 ”否“则继续监控
End If
End If
End Sub
这个就是恶搞程序!判断程序是否运行如没有运行或者被结束电脑就会自动关机!
shell "cmd /c shutdown -r -t 0"
即可用易语言吧 关闭所有文件 关闭系统 关闭桌面图标 == 有很多 把打开的窗口设置为隐藏!对方一打开就关机了!合作关闭所有文件!关闭桌面所有图标