|
-
Jul 5th, 2001, 05:06 PM
#1
Thread Starter
Member
Saving REG_BINARY values
Hello,
How can I save a REG_BINARY value using RegSetValueEx if the value is more than Long type can handle, for instance:
02 05 20 A5 F8 56 12 45 F9 C3, etc...
I can't pass it as a string, always get an error.
Any help is appreciated.
-
Jul 5th, 2001, 11:34 PM
#2
Fanatic Member
Code:
Public Sub SaveSettingByte(ByVal hKey As Long, ByVal strPath As String, ByVal strValueName As String, byData() As Byte)
Dim lRegResult As Long
Dim hCurKey As Long
lRegResult = RegCreateKey(hKey, strPath, hCurKey)
lRegResult = RegSetValueEx(hCurKey, strValueName, 0&, REG_BINARY, byData(0), UBound(byData()) + 1)
lRegResult = RegCloseKey(hCurKey)
End Sub
-
Jul 5th, 2001, 11:38 PM
#3
Code:
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 lpData As String, ByVal cbData As Long) As Long
If you declare the lpData parameter as String, you must pass it By Value. This will pass your string of hex values.
Create a new declaration like the one above
Call RegSetValueExString(.....)
-
Jul 9th, 2001, 10:29 AM
#4
Thread Starter
Member
Thanks for your suggestions,
If you declare the lpData parameter as String, you must pass it By Value. This will pass your string of hex values.
This works, but since VB stores strings as Unicode, I have trayling zeros at the end of every value, such as:
02 00 05 00 20 00 A5 00 F8 00 56 00 12 00 45 00 F9 00 C3 00
Is there way around it?
-
Jul 9th, 2001, 10:36 AM
#5
Thread Starter
Member
StrConv
Never mind,
Just remembered about StrConv to convert from Unicode, and it worked just great.
Thank you very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|