| 首页 | 技术文章 | 软件下载 | 博客 | 论坛 | 精品教程 | 黑客动画 | 视频资源 | 在线服务 | 黑客游戏 | 

您现在的位置: 中国X黑客小组 >> 技术文章 >> 编程技术 >> 程序设计 >> 文章正文 用户登录 新用户注册
  VB与注册表          【字体:
VB与注册表
作者:未知    文章来源:CnXHacker.Net    点击数:    更新时间:2006-10-26    

1:可以把选项保存在文件、数据库或注册表中,然后在程序启动时加入ComboBox。这样每次你只需要修改文件或注册表就可以了,而不需要重新编译程序。下面的例子就是从注册表中读取:
Private Sub Form_Load()
Dim s As String
Dim i As Integer

i = 0
Do
s = GetSetting(appname := "MyApp", section := "Startup", _
key := i, default := "")
If s <> "" Then Combo1.AddItem s
i = i + 1
Loop Until s = ""
End Sub

2:打开注册表: Shell "regedit.exe", vbNormalFocus。
RegSetValueEx 函数
3:Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
在一个注册表项下设置一个指定值的数据和类型
hKey 当前打开项的句柄
lpValueName 要设置值的名称
Reserved 未用,设为0
dwtype 要设置值的数据类型
lpdata 要设置值的数据
cbData 缓冲区的长度
RegSetValue 函数
Public Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
在一个注册表项下设置一个指定值的数据和类型
hkey 当前打开项的句柄
lpSubKey 注册表新子项的名称
dwType 要设置值的数据类型
lpData 要设置值的数据
cbData 缓冲区的长度
RegCreateKey 函数
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
在指定的项下创建一个新项,如果指定的项已存在,则打开这个项
hKey 当前打开项的句柄。
lpSubKey 注册表新子项的名称
phkresult 指定一个变量,装载新子项的句柄
RegDeleteKey 函数
Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
hKey 当前打开项的句柄
lpSubKey 要删除项的值的名称,如果设为VBNULLSTRING 或 “” ,是删除指定的默认值
RegCloseKey
Public Declare Function RegCloseKey Lib "advapi32.dll" Alias "RegCloseKey" (ByVal hKey As Long) As Long
hKey 当前打开项的句柄 函数
RegOpenKey
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

hKey 当前打开项的句柄 函数
lpSubKey 要打开项的名称
phkresult 指定一个变量,装载新子项的句柄

在工程运行前,使之自动存盘
HKEY_CURRERT_USER\Software\Microsoft\Visual Basic\6.0
"saveBeforeRun" 1

用VB备份注册表单个分支
Private Sub Command1_Click()
Shell "regedit /e e:\11.reg HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
End Sub
用VB备份整个注册表
Shell "regedit /e e:\11.reg"

直接导入注册表
Shell "regedit c:\windows\system32\电脑优化.reg"
SendKeys "{enter}",True

shell "regedit /s e:\11.reg"

文章录入:IceRiver    责任编辑:IceRiver 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    “VB蠕虫变种MQ”病毒技术细
    VB.NET 拖动无边框窗体编程实
    病毒清除技巧u.vbe和u.bat手
    了解VB编写病毒的大体方法
    用vbs来写sql注入等80端口的
    详细解说“黑掉”Dvbbs 7.1 
    黑客技巧之用VB实现木马式隐
    使用GDB与QEMU调试内核时的问
    多进程的VBS脚本编写刷票机
    VB打造另类下载者
      网友评论:(只显示最新5条。评论内容只代表网友观点,与本站立场无关!)
    Powered by ICE RIVER - STUDIO
    » CnXHacker.CoM   © CopyRight 2002-2006, CnXHacker.CoM™, Inc. All Rights Reserved.