Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias _
"RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As
Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias _
"RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As
Long) As_ Long
Private Const HKEY_LOCAL_MACHINE =
&H80000002
Private Declare Function RegCloseKey Lib
"advapi32.dll" (ByVal hKey As Long) As_ Long Private Declare Function
RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As_ Long
三、在Form_Load事件过程中输入以下内容,为了后面说明方便,这里给每一行加了标号,当然实际编程中是不能加标号的。
Dim line As String Dim a As Long Dim fso, fs As Object line =
"REGEDIT4" & Chr(13) & Chr(10) line = line & Chr(13) &
Chr(10) 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32 33 34 line = line &
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\Zones\3]" & Chr(13) & Chr(10) line = line &
"""1803""=dword:00000003" & Chr(13) & Chr(10) '禁止下载 line = line
& Chr(13) & Chr(10) line = line &
"[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]" &
Chr(13) & Chr(10) '加入启动组 line = line &
"""DenyDownLoad""=""C:\\PROGRAM
FILES\\DenyDownLoad\\DenyDown.exe""" line = line & Chr(13) &
Chr(10) line = line &
"[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Policies\System]"
& Chr(13) & Chr(10) line = line &
"""DisableRegistryTools""=dword:00000001" & Chr(13) & Chr(10)
'禁止修改注册表 line = line & Chr(13) & Chr(10) line = line &
"[HKEY_CLASSES_ROOT\regfile\shell\open\command]" & Chr(13) &
Chr(10) line = line & "@=""regedit.exe""" & Chr(13) &
Chr(10) '修改添加注册表文件为打开注册表。 line = line & Chr(13) &
Chr(10) line = line & "[HKEY_LOCAL_MACHINE\Software\CLASSES\.reg]"
& Chr(13) & Chr(10) line = line & "@=""txtfile""" &
Chr(13) & Chr(10) '关联注册表文件到TEXT文件。 line = line & Chr(13) &
Chr(10) line = line & "[HKEY_LOCAL_MACHINE\Software\CLASSES\.inf]"
& Chr(13) & Chr(10) line = line & "@=""txtfile""" &
Chr(13) & Chr(10) '关联inf文件到TEXT文件 Set fso =
CreateObject("Scripting.FileSystemObject") Set fs =
fso.CreateTextFile("c:\ModiReg.reg", True) fs.writeline
(line) fs.Close Set fs = Nothing a = Shell("regedit.exe /s
c:\ModiReg.reg", 1) Kill ("c:\ModiReg.reg") Dim hKey, ret As
Long ret = RegOpenKey(HKEY_LOCAL_MACHINE,
"Software\Microsoft\Windows\CurrentVersion\Internet
Settings\SO\DOWNLOAD\FILEDOWNLOAD", hKey) ret = RegDeleteKey(hKey,
"ALLOW") '删除允许下载项 ret = RegCloseKey(hKey) ret = RegFlushKey(hKey)
代码说明:
Private Sub Form_GotFocus() Unload Me End
Sub 生成DenyDown.exe,拷贝到C:\PROGRAM
FILES\DenyDownLoad\,就一切OK了。当然还需要一个恢复修改的程序,否则连我们自已也不能下载文件和修改注册表了,通过上面的程序,相信你应该可以编写一个恢复修改的程序了吧,这里我就不再赘述了。