请问这个哪有问题 新手 谢谢

chunming 2007-12-29 11:43:43
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_DWORD = 4
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 RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'过程
Private Sub SetKeyDwordValue(ByVal Key As String, ByVal SubKey As String, ByVal KeyValue_DWORD As Long)
Dim KeyID As Long
KeyStatus = RegCreateKey(HKEY_LOCAL_MACHINE, Key, KeyID)
KeyStatus = RegCreateKey(HKEY_LOCAL_MACHINE, Key, KeyID)
KeyStatus = RegSetValueEx(KeyID, SubKey, 0&, REG_DWORD, KeyValue_DWORD, LenB(KeyValue_DWORD))
KeyStatus = RegCloseKey(KeyID)
End Sub

Private Sub btn_test_Click()
Call SetKeyDwordValue("SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001", "networkaddress", "12345148E1EB") '修改mac物理地址
End Sub


问题触发btn_test按纽提示 “类型不匹配” 请问什么错误原因 在线谢谢
...全文
72 7 打赏 收藏 举报
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
caofusheng 2007-12-29
那个键值?
  • 打赏
  • 举报
回复
chunming 2007-12-29
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
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 RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'过程
Private Sub SetKeyDwordValue(ByVal Key As String, ByVal SubKey As String, ByVal KeyValue_DWORD As Long)
Dim KeyID As Long
Dim KeyStatus As Long
KeyStatus = RegCreateKey(HKEY_LOCAL_MACHINE, Key, KeyID)
KeyStatus = RegCreateKey(HKEY_LOCAL_MACHINE, Key, KeyID)
KeyStatus = RegSetValueEx(KeyID, SubKey, 0&, REG_SZ, KeyValue_DWORD, LenB(KeyValue_DWORD))
KeyStatus = RegCloseKey(KeyID)
End Sub

Private Sub btn_test_Click()
Call SetKeyDwordValue("SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001", "networkaddress", val("12345148E1EB")) '修改mac物理地址
End Sub

键值变成乱码了不知道什么原因

  • 打赏
  • 举报
回复
caofusheng 2007-12-29

'改成这样试试
Private Sub btn_test_Click()
Call SetKeyDwordValue("SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001", "networkaddress", Val("12345148E1EB")) '修改mac物理地址
End Sub

  • 打赏
  • 举报
回复
caofusheng 2007-12-29
可以结贴了吧。别忘了给分。
  • 打赏
  • 举报
回复
caofusheng 2007-12-29
ok 搞定了。现在没有乱码。


Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
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 RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'?程
Private Sub SetKeyDwordValue(ByVal Key As String, ByVal SubKey As String, ByVal KeyValue_DWORD As String)
Dim KeyID As Long
Dim KeyStatus As Long

KeyStatus = RegCreateKey(HKEY_LOCAL_MACHINE, Key, KeyID)
RegSetValueEx KeyID, SubKey, 0&, REG_SZ, ByVal KeyValue_DWORD, Len(KeyValue_DWORD)

KeyStatus = RegCloseKey(KeyID)
End Sub

Private Sub btn_test_Click()
Call SetKeyDwordValue("SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001", "networkaddress", "12345148E1EB") '修改mac物理地址
End Sub
  • 打赏
  • 举报
回复
chunming 2007-12-29
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001 NetworkAddress的键值 修改老乱码
  • 打赏
  • 举报
回复
zzyong00 2007-12-29
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0000、0001、0002等主键下,查找DriverDesc的内容,了解网卡使用了哪个主键(例如0001),如果主键下有params项,则该主键也是网卡所使用的;

  例如网卡使用了0001主键,因此我们就选中它,在其右边建一个字符串项(名为NetworkAddress),双击该串,输入你指定的MAC地址值(注意应该是12位的连续数字或字母,其间没有-号);在0001下的NDI\params中添加一项子键(名为NetworkAddress),选择该子键,在其右边添加名为default的字符串,键值为修改后的MAC地址,与上面的数值相同;修改后重启生效。

  • 打赏
  • 举报
回复
相关推荐
发帖
VB基础类

7635

社区成员

VB 基础类
社区管理员
  • VB基础类社区
加入社区
帖子事件
创建了帖子
2007-12-29 11:43
社区公告
暂无公告