1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Public Const REG_BINARY = 3 ' Binary
Public Function getBinary(Hkey As Long, strPath As String, strValue As String) As Byte()
Dim keyhand As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf() As Byte
Dim lDataBufSize As Long
Dim i As Long
r = RegOpenKey(Hkey, strPath, keyhand)
lResult = RegQueryValueEx(keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_BINARY Then
ReDim strBuf(1 To lDataBufSize) As Byte
lResult = RegQueryValueEx(keyhand, strValue, 0&, 0&, strBuf(1), lDataBufSize)
If lResult = ERROR_SUCCESS Then
getBinary = strBuf
End If
End If
End Function
Public Sub SaveBinary(Hkey As Long, strPath As String, strValue As String, binaryData() As Byte)
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_BINARY, binaryData(LBound(binaryData)), UBound(binaryData) - LBound(binaryData) + 1)
r = RegCloseKey(keyhand)
End Sub |
Partager