不用API,也能玩注册表--vb !(downmoon原创)
补充: 需新建四个command ,
名称依次为
write_reg
read_reg
del_reg
reg_run
对应Caption为:
建立新键
读取注册表
删除新键
启动自运行
OK!
代码如下:
´****************************************************
´请务必引用 “Windows Script Host Object Model" Lib
´
´****************************************************
´
´****************************************************
´ Note:
´
´需引用“Windows Script Host Object Model" Lib
´"HKLM" 指 "HKEY_LOCAL_MACHINE"
´"HKCU" 指 "HKEY_CURRENT_USER"
´其它几个注册表主键依次类推,但必须大写
´适用于vb 6 简体中文版
´可以读出瑞星的安装ID
´
´******************************************************
´ by Downmoon
´
´ QQ: 23409408
´
´
´
´ 2003-2-16
´
´*****************************************************
Option Explicit
Dim mynumber As Integer
Private Reg
Private Sub del_reg_Click()
Dim Cancel As Integer
Dim mydelete As String
If MsgBox("Are u sure to delete" & vbTab & "HKLM\SOFTWARE\Rising\Rav\MyRising" & vbTab & "?", vbYesNo, "确认前先保存注册表!!!") = vbNo Then
Cancel = True
Else
mydelete = Reg.RegDelete("HKLM\SOFTWARE\Rising\Rav\MyRising")
MsgBox " Already Deleted!!!!" & vbTab & Chr(13) & "HKLM\SOFTWARE\Rising\Rav\MyRising==== D:\rising\Rav\Rav.exe"
End If
End Sub
Private Sub Form_Load()
mynumber = 0
Set Reg = New IWshShell_Class
End Sub
Private Sub Form_Unload(Cancel As Integer)
ilovedownmoon.Caption = "再见"
If ilovedownmoon.WindowState <> 1 Then
Dim I As Long
For I = 50 To ilovedownmoon.Height
If ilovedownmoon.Height > 400 Then
ilovedownmoon.Height = ilovedownmoon.Height - 30
End If
Next I
For I = 50 To ilovedownmoon.Width
If ilovedownmoon.Width > 500 Then
ilovedownmoon.Width = ilovedownmoon.Width - 30
End If
Next I
End If
End
End Sub
Private Sub read_reg_Click()
MsgBox ("^_^! Your rising ID is :" & Chr(13) & Chr(13) & Chr(13) & vbTab & Reg.RegRead("HKLM\SOFTWARE\Rising\Rav\NetID") & Chr(13) & Chr(13) & Chr(13) & Chr(13) & vbTab & "OK?")
End Sub
Private Sub reg_run_Click()
On Error Resume Next
Dim myrun As String
Dim mynorun As String
If mynumber \ 2 = 0 Then
myrun = Reg.RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\cdplayer", "C:\WINNT\system32\cdplayer.exe", "REG_SZ")
MsgBox (Chr(13) & vbTab & "added " & Chr(13) & vbTab & vbTab & "C:\WINNT\system32\cdplayer.exe" & Chr(13) & vbTab & "into AutoRun!")
reg_run.Caption = "取消自运行"
´测试
´Label1.Caption = mynumber
GoTo num
Else
mynorun = Reg.RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\cdplayer")
MsgBox (Chr(13) & vbTab & "Deleted " & Chr(13) & vbTab & vbTab & "C:\WINNT\system32\cdplayer.exe" & Chr(13) & vbTab & "out of AutoRun!")
reg_run.Caption = "启动自运行"
´测试
´Label1.Caption = mynumber
GoTo num
End If
num:
mynumber = mynumber + 1
End Sub
Private Sub write_reg_Click()
Dim Cancel As Integer
Dim mytest As String
If MsgBox("Really write" & vbTab & "HKLM\SOFTWARE\Rising\Rav\MyRising" & vbTab & "?", vbYesNo, "确认前先保存注册表!!!") = vbNo Then
Cancel = True
Else
mytest = Reg.RegWrite("HKLM\SOFTWARE\Rising\Rav\MyRising", "D:\rising\Rav\Rav.exe", "REG_SZ")
´REG_SZ 表示键的类型,为缺省值。
MsgBox "HKLM\SOFTWARE\Rising\Rav\MyRising==== D:\rising\Rav\Rav.exe" & vbTab & Chr(13) & "Writed!!!!!"
End If
End Sub
文章来源于领测软件测试网 https://www.ltesting.net/