CSDN博客

img downmoon

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

发表于2003/2/26 8:48:00  2233人阅读

不用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
'
'
        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 ( " Are u sure to delete "   &  vbTab  &   " HKLMSOFTWARERisingRavMyRising "   &  vbTab  &   " ? " , vbYesNo,  " 确认前先保存注册表!!! " =  vbNo  Then
            Cancel 
=   True
            
Else
                       
            mydelete 
=  Reg.RegDelete( " HKLMSOFTWARERisingRavMyRising " )

MsgBox   "  Already Deleted!!!! "   &  vbTab  &   Chr ( 13 &   " HKLMSOFTWARERisingRavMyRising==== D: isingRavRav.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( " HKLMSOFTWARERisingRavNetID " &   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( " HKLMSOFTWAREMicrosoftWindowsCurrentVersionRuncdplayer " " C:WINNTsystem32cdplayer.exe " " REG_SZ " )
MsgBox  ( Chr ( 13 &  vbTab  &   " added  "   &   Chr ( 13 &  vbTab  &  vbTab  &   " C:WINNTsystem32cdplayer.exe "   &   Chr ( 13 &  vbTab  &   " into  AutoRun! " )
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  &   " 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  &   " 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
End Sub
0 0

相关博文

我的热门文章

img
取 消
img