做高手不给菜鸟做主,不如回家卖红薯!!!!

lengxue 2000-09-08 02:47:00
我有这样一长串数字“dd de df ab c3 9c 9c 9c
da ff df ab c3 9c 9c 9c
ee de df ab c3 9c 9c 9c
aa de df ab c3 9c 9c 99"
怎样写入注册表中的HKEY_CURRENT_USER\RemoteAccess\Addresses\xinjun中?
我是个菜鸟中的菜鸟,什么都不会的!
请各为高手帮忙!希望原代码!!!!!!

我搞了这么个东东:
Public Sub savestring(hKey As Long, strPath As String, strValue As String, strdata As Byte)
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(hKey, strPath, keyhand)
r = RegOpenKey(hKey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, reg_binary, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
End Sub

然后就

Call savestring(HKEY_LOCAL_MACHINE, "RemoteAccess\Addresses", "xinjun", "1234")

然而写进去的不是1234而是一些莫名其妙的东西,而且数字一长就出错!!!!
怎么搞啊?

...全文
237 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shines77 2000-09-12
  • 打赏
  • 举报
回复
大虾,给分啊!
shines77 2000-09-10
  • 打赏
  • 举报
回复
卖红薯喽,大家快来吃啊:))我请客!!
shines77 2000-09-10
  • 打赏
  • 举报
回复
大家不用买红薯了,不过这个点子倒是不错,请把分数给我吧:) 不要食言

Option Explicit

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 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 Const REG_SZ = 1 ' Unicode nul terminated string
Private Const REG_BINARY = 3 ' Free form binary
Private Const REG_DWORD = 4 ' 32-bit number

Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003

Private Sub Form_Load()
Dim YourString As String
'你要写入的字符串
YourString = "dd de df ab c3 9c 9c 9c" + _
"da ff df ab c3 9c 9c 9c" + _
"ee de df ab c3 9c 9c 9c" + _
"aa de df ab c3 9c 9c 99"
Dim i As Long
Dim Length As Long
Dim strByte() As Byte
Length = Int((Len(YourString) - 1) / 3)
ReDim strByte(Length)
For i = 0 To Length
strByte(i) = CByte(Val("&H" + Mid(YourString, i * 3 + 1, 2)))
Next i
'写入字符串
SaveString HKEY_CURRENT_USER, "RemoteAccess\Addresses", "xinjun", strByte
End Sub

Public Sub SaveString(hKey As Long, strPath As String, strValue As String, strData() As Byte)
Dim KeyHand As Long
Dim r As Long
r = RegCreateKey(hKey, strPath, KeyHand)
r = RegOpenKey(hKey, strPath, KeyHand)
r = RegSetValueEx(KeyHand, strValue, 0, REG_BINARY, strData(0), UBound(strData) - LBound(strData) + 1)
r = RegCloseKey(KeyHand)
End Sub
lengxue 2000-09-09
  • 打赏
  • 举报
回复
帮帮忙!
Liubin 2000-09-09
  • 打赏
  • 举报
回复
我还是去卖红薯好了。
who 2000-09-09
  • 打赏
  • 举报
回复
kao,凭什么不给你帮忙就得卖红薯呀?
活该没人帮忙
这都不会做还不如自己去卖红薯好了

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧