几行VB代码拿下注册表_VB.net_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

几行VB代码拿下注册表

作者:黑客防线网安VB教程基地 来源:黑客防线网安VB教程基地 浏览次数:0

本篇关键词:注册表代码 ByVal
黑客防线网安网讯:大家好,下面是我写的关于注册表操作的常用函数,希望对大家有所帮助'****************************注册表操作函数**********************'声明:以下代码由轻风工作室REDICE编写,...

大家好下面是我写的关于注册表操作的常用函数希望对大家有所帮助

'****************************注册表操作函数**********************
'声明:以下代码由轻风工作室REDICE编写,引用时请作一说明
'****************************************************************

'*****下面先声明一些常量******************************************
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_DYN_DATA = &H80000006
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const REG_OPTION_NON_VOLATILE = 0
Public Const KEY_ALL_ACCESS = (&H20000 Or &H1 Or &H2 Or &H4 Or &H8 Or &H10 Or &H20) And (Not &H100000)
Public Const REG_SZ = 1
Public Const REG_DWORD = 4
'*****************************************************************

'*****下面声明注册表操作中用到的API函数****************************
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal uloptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
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
Public Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Public Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
'*****************************************************************

'*****下面是我自己写的一些注册表操作中常用的一些函数**************
'*****新键注册表项
Public Function createnewkey(ip As Long, snewkeyname As String)
    Dim hnewkey As Long
    Dim retval As Long
    retval = RegCreateKey(ip, snewkeyname, hnewkey)
    If retval = 0 Then
       RegCloseKey (hnewkey)   '关闭上面建立或打开的项
    End If
End Function
'实例:在HKEY_CURRENT_USER下建立项"xiaopeng"
'代码为 createnewkey HKEY_CURRENT_USER ,"xiaopeng"
'******************************************************************

'*******删除注册表项***********************************************
Public Function deletekey(ip As Long, skeyname As String)
    Dim hKey As Long
    Dim retval As Long
    retval = RegOpenKeyEx(ip, skeyname, 0, KEY_ALL_ACCESS, hKey)
    If retval = 0 Then
       RegDeleteKey ip, skeyname
    End If
End Function
'实例:删除上面建立的HKEY_CURRENT_USER下的项"xiaopeng"
'代码为 deletekey HKEY_CURRENT_USER ,"xiaopeng"
'******************************************************************

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-14764-1.html
网站维护教程更新时间:2012-04-03 01:14:00  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer