• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

不用API,也能玩注册表--vb !(downmoon原创)

发布: 2007-7-01 21:48 | 作者: admin | 来源: | 查看: 11次 | 进入软件测试论坛讨论

领测软件测试网

不用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/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网