| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3372 人关注过本帖
标题:求VB修改注册表
取消只看楼主 加入收藏
dao1975
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-1
收藏
 问题点数:0 回复次数:2 
求VB修改注册表
我在编一个程序时需要修改注册表的一个值,其类型为REG_BINARY,其值为“91000000”,但不知要怎么写,我写的是这样的:
API函数声明已有
Private Const REG_BINARY = 3&
API函数声明已有,在此我就省了
   dim c as long
   c = “91000000”  
   RegCreateKey HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", hKey
   RegSetValueEx hKey, "NoDriveTypeAutoRun", 0&, REG_BINARY, c, 3
   RegCloseKey hKey

写入后内容就不是如:0000  91 00 00 00了,请高手指点下,只要VB编写的,

  导出的注册文件内容(正确的)是这样的:
  Windows Registry Editor Version 5.00
  [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
  "NoDriveTypeAutoRun"=hex:91,00,00,00
搜索更多相关主题的帖子: 注册表 
2008-09-01 07:05
dao1975
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-1
收藏
得分:0 
楼上说的我全都声明过的,不行的
Private 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
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKeyExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long


Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const REG_SZ = 1&
Private Const REG_EXPAND_SZ = 2&
Private Const REG_BINARY = 3&
Private Const REG_DWORD = 4&
Private Const ERROR_SUCCESS = 0&


Private Sub Command1_Click()
Dim hKey As Long
Dim a As Long
 a = "91000000"  
RegCreateKey_
HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",hKey

RegSetValueEx hKey, "NoDriveTypeAutoRun", 0&, REG_BINARY, a, 3

RegCloseKey hKey

End Sub

  以上就是我编的全码,不行的,请高手指点下,网上找不到



   另说下二楼的那位朋友如要用 shell调用 我就不会在此求助了,不用你说我都会,要的是VB写的独立程序

[[it] 本帖最后由 dao1975 于 2008-9-1 15:50 编辑 [/it]]
2008-09-01 15:46
dao1975
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-1
收藏
得分:0 
太谢谢我楼上的这位朋友了,你给的代码完全通过,写入里面后的二进制内容正是我所要 0000 91 00 00 00      .... 在次谢谢你了!
2008-09-02 08:19
快速回复:求VB修改注册表
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033807 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved