VB读取注册表键值

VB怎样读取指定项的键值,例如,HKEY_CURRENT_USER/AppEvents/EventLabels/.Default下有一个REG_SZ类型的项DispFileName,值是@mmsys.cpl,-5824,用VB怎样读取,不要脚本文件

第1个回答  2012-01-07
如果使用的是VB6的话可以使用API函数来完成。
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
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
Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
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
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
Private Declare Function RegDeleteKey& Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String)
Private Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String)

发信给我tmp_for_reg@163.com给你具有DeleteKey,DeleteValue,SetValueEx,QueryValueEx,CreateNewKey,SetKeyValue,QueryValue的代码。
第2个回答  2012-01-07
我记得好像有个API,去查查API吧,然后再VB搜索声明就OK了

哪位大神有vb读取注册表键值的代码,多谢
1.RegWrite 语法示例:RegWrite 'HKCU\\Software\\oldghost\\test', 'abc', 'REG_SZ'参数说明:第一个参数中,'HKCU\\Software\\oldghost\\',这是个主键及子键,'test'是值项。第二个参数就是值项的键值。第三个参数是键值的类型。注册表值的类型我就不说了,有疑问自己查。功能简介:在注册表中...

VB中如何读取注册表中某个值
1、使用RegOpenKeyEx或RegCreateKeyEx函数打开或创建一个键;2、如果上一步成功,使用RegQueryValueEx读取子键的值,使用RegSetValueEx设置子键值,使用RegEnumKey获得所有子键,使用RegDeleteKey删除一个键;3、完成操作后使用RegCloseKey关闭键。下面这段程序打开HKEY_CURRENT_USER\\Software\\Zeal SoftStudio\\AskPro ...

VB读注册表数值名称的问题
’为了便于观察,调试可以在此处设置断点,同时切换到注册表,按下键刷新,即可看到自己建立的子键及其键值 DeleteSetting “我的工程”, “我的子键” ’运行完毕后再次切换到注册表并按下键刷新,观察己建立的子键及其键值是否被删除 说明: 运行本程序前,需先确保启动VB时已自动加载“API文本浏览器”,且在API文本浏...

vb 注册表 regread
你的是读取注册表键值!是读取HKEY_CURRENT_USER\\Software\\Microsoft\\WindowsNT\\CurrentVersion\\WindowsMessagingSubsystem\\Profiles\\Outlook\\9375CFF0413111d3B88A00104B2A6676\\{ED475418-B0D6-11D2-8C3B-00104B2A6676}的键值吧,你该不会是把"{ED475418-B0D6-11D2-8C3B-00104B2A6676}"当做值还要读??

关于检测VB注册表下子键下键值项的问题
'读取方法如下 Dim mWshShell,a Set mWshShell = CreateObject("Wscript.Shell")a = mWshShell.RegRead("HKLM\\SOFTWARE\\Tencent\\AAA")Set mWshShell=nothing '如果没有 键值,会报 -2147024894 错,这样就可以通过捕捉错误来判断有没有键

vb如何读注册表某一键下的所有子键名字
2.使用RegEnumKeyEx进行枚举.函数声明 Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long,ByVal lpName As String,lpcbName As Long, ByVal lpReserved As Long,ByVal lpClass As String,lpcbClass As Long, lpft...

VB操作注册表完整代码和详细注释
1、增加键值:WSH.regWrite "注册表完整路径键值名",键值,"键值类型"注:regWrite方法的键值类型常用的有:REG_BINARY(新建或写入二进制值)、REG_DWORD(新建或写入DWORD值)、REG_SZ(新建或写入字符串值)。2、获取键值:Ret=WSH.RegRead("注册表完整路径键值名")注:RegRead方法的返回赋给变量...

如何在VB中读取到注册表的某个地址的指定字符串值的数值数据
StrTmp = vbsShell.regread("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Abc\\Def\\xyz")MsgBox StrTmp '你要保证你的注册表里存在xyz这样一个项.否则会报错.'还有一个出错的原因是你的系统不支持WSCript '如果是第二个原因,你可以用API函数,代码会多点.以下是用API读注册表的源程序,希望对你有所...

小弟请教,如何用vb读取注册表HKEY_LOCAL_MACHINE\\SOFTWARE\\Tencent\\QQ...
'读取键值 Private Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long Dim cch As Long Dim lrc As Long Dim lType As Long Dim lValue As Long Dim sValue As String On Error GoTo QueryValueExError lrc = RegQueryValueExNULL(lhKey,...

VB怎么查看注册表的某一样??
如果注册表读取不到这个注册表的键值,是会出错的,所以设置当出错时,提示没有安装QQ就行了..Private Sub Command1_Click()On Error GoTo err Set Reg = CreateObject("Wscript.Shell")s = Reg.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Tencent\\QQ\\Install")Shell s & "QQ.exe"Exit Sub err:MsgBox ...

相似回答
大家正在搜