在不使用API的情况下玩注册表的方法
在不使用API的情况下玩注册表的方法
不用API,也能玩注册表--vb !(downmoon原创)
补充: 需新建四个command ,
名称依次为
write_reg
read_reg
del_reg
reg_run
对应Caption为:
建立新键
读取注册表
删除新键
启动自运行
OK!
代码如下:
' ****************************************************
' 请务必引用“WindowsScriptHostObjectModel"Lib
'
' ****************************************************
'
' ****************************************************
' Note:
'
' 需引用“WindowsScriptHostObjectModel"Lib
' "HKLM"指"HKEY_LOCAL_MACHINE"
' "HKCU"指"HKEY_CURRENT_USER"
' 其它几个注册表主键依次类推,但必须大写
' 适用于vb6简体中文版
' 可以读出瑞星的安装ID
'
' ******************************************************
' byDownmoon
'
' QQ:23409408
'
' 1000sun@163.com
'
' 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 ( " Areusuretodelete " & vbTab & " HKLMSOFTWARERisingRavMyRising " & vbTab & " ? " ,vbYesNo, " 确认前先保存注册表!!! " ) = vbNo Then
Cancel = True
Else
mydelete = Reg.RegDelete( " HKLMSOFTWARERisingRavMyRising " )
MsgBox " AlreadyDeleted!!!! " & vbTab & Chr ( 13 ) & " HKLMSOFTWARERisingRavMyRising====D: isingRavRav.exe "
End If
EndSub
Private Sub Form_Load()
mynumber = 0
Set Reg = New IWshShell_Class
EndSub
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
EndSub
Private Sub read_reg_Click()
MsgBox ( " ^_^!YourrisingIDis: " & Chr ( 13 ) & Chr ( 13 ) & Chr ( 13 ) & vbTab & Reg.RegRead( " HKLMSOFTWARERisingRavNetID " ) & Chr ( 13 ) & Chr ( 13 ) & Chr ( 13 ) & Chr ( 13 ) & vbTab & " OK? " )
EndSub
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( " HKLMSOFTWAREMicrosoftWindowsCurrentVersionRuncdplayer " , " C:WINNTsystem32cdplayer.exe " , " REG_SZ " )
MsgBox ( Chr ( 13 ) & vbTab & " added " & Chr ( 13 ) & vbTab & vbTab & " C:WINNTsystem32cdplayer.exe " & Chr ( 13 ) & vbTab & " intoAutoRun! " )
reg_run.Caption = " 取消自运行 "
' 测试
' Label1.Caption=mynumber
GoTo num
Else
mynorun = Reg.RegDelete( " HKLMSOFTWAREMicrosoftWindowsCurrentVersionRuncdplayer " )
MsgBox ( Chr ( 13 ) & vbTab & " Deleted " & Chr ( 13 ) & vbTab & vbTab & " C:WINNTsystem32cdplayer.exe " & Chr ( 13 ) & vbTab & " outofAutoRun! " )
reg_run.Caption = " 启动自运行 "
' 测试
' Label1.Caption=mynumber
GoTo num
End If
num:
mynumber = mynumber + 1
EndSub
Private Sub write_reg_Click()
Dim Cancel As Integer
Dim mytest As String
If MsgBox ( " Reallywrite " & vbTab & " HKLMSOFTWARERisingRavMyRising " & vbTab & " ? " ,vbYesNo, " 确认前先保存注册表!!! " ) = vbNo Then
Cancel = True
Else
mytest = Reg.RegWrite( " HKLMSOFTWARERisingRavMyRising " , " D: isingRavRav.exe " , " REG_SZ " )
' REG_SZ表示键的类型,为缺省值。
MsgBox " HKLMSOFTWARERisingRavMyRising====D: isingRavRav.exe " & vbTab & Chr ( 13 ) & " Writed!!!!! "
End If
EndSub
' 请务必引用“WindowsScriptHostObjectModel"Lib
'
' ****************************************************
'
' ****************************************************
' Note:
'
' 需引用“WindowsScriptHostObjectModel"Lib
' "HKLM"指"HKEY_LOCAL_MACHINE"
' "HKCU"指"HKEY_CURRENT_USER"
' 其它几个注册表主键依次类推,但必须大写
' 适用于vb6简体中文版
' 可以读出瑞星的安装ID
'
' ******************************************************
' byDownmoon
'
' QQ:23409408
'
' 1000sun@163.com
'
' 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 ( " Areusuretodelete " & vbTab & " HKLMSOFTWARERisingRavMyRising " & vbTab & " ? " ,vbYesNo, " 确认前先保存注册表!!! " ) = vbNo Then
Cancel = True
Else
mydelete = Reg.RegDelete( " HKLMSOFTWARERisingRavMyRising " )
MsgBox " AlreadyDeleted!!!! " & vbTab & Chr ( 13 ) & " HKLMSOFTWARERisingRavMyRising====D: isingRavRav.exe "
End If
EndSub
Private Sub Form_Load()
mynumber = 0
Set Reg = New IWshShell_Class
EndSub
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
EndSub
Private Sub read_reg_Click()
MsgBox ( " ^_^!YourrisingIDis: " & Chr ( 13 ) & Chr ( 13 ) & Chr ( 13 ) & vbTab & Reg.RegRead( " HKLMSOFTWARERisingRavNetID " ) & Chr ( 13 ) & Chr ( 13 ) & Chr ( 13 ) & Chr ( 13 ) & vbTab & " OK? " )
EndSub
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( " HKLMSOFTWAREMicrosoftWindowsCurrentVersionRuncdplayer " , " C:WINNTsystem32cdplayer.exe " , " REG_SZ " )
MsgBox ( Chr ( 13 ) & vbTab & " added " & Chr ( 13 ) & vbTab & vbTab & " C:WINNTsystem32cdplayer.exe " & Chr ( 13 ) & vbTab & " intoAutoRun! " )
reg_run.Caption = " 取消自运行 "
' 测试
' Label1.Caption=mynumber
GoTo num
Else
mynorun = Reg.RegDelete( " HKLMSOFTWAREMicrosoftWindowsCurrentVersionRuncdplayer " )
MsgBox ( Chr ( 13 ) & vbTab & " Deleted " & Chr ( 13 ) & vbTab & vbTab & " C:WINNTsystem32cdplayer.exe " & Chr ( 13 ) & vbTab & " outofAutoRun! " )
reg_run.Caption = " 启动自运行 "
' 测试
' Label1.Caption=mynumber
GoTo num
End If
num:
mynumber = mynumber + 1
EndSub
Private Sub write_reg_Click()
Dim Cancel As Integer
Dim mytest As String
If MsgBox ( " Reallywrite " & vbTab & " HKLMSOFTWARERisingRavMyRising " & vbTab & " ? " ,vbYesNo, " 确认前先保存注册表!!! " ) = vbNo Then
Cancel = True
Else
mytest = Reg.RegWrite( " HKLMSOFTWARERisingRavMyRising " , " D: isingRavRav.exe " , " REG_SZ " )
' REG_SZ表示键的类型,为缺省值。
MsgBox " HKLMSOFTWARERisingRavMyRising====D: isingRavRav.exe " & vbTab & Chr ( 13 ) & " Writed!!!!! "
End If
EndSub