Hola en el proyecto actual que estoy haciendo estoy con el registro de windows, tengo algun que otro problemilla al leer los valores, cuando los valores son DWORD, no consigo leer su valor, les pongo el codigo:
Public Function ValueData(Key As Long, strValueName As String, sType As Long) As String
Dim lResult As Long, RetornoData As Long, strData As String, lngData As Currency, binData() As Byte, sTmp As String
Dim i As Integer
Select Case sType
Case REG_NONE
ValueData = vbNullString
Case REG_SZ, REG_EXPAND_SZ, REG_LINK
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal 0, RetornoData)
If lResult = 0 Then
strData = String(RetornoData, Chr$(0))
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal strData, RetornoData)
If lResult = 0 Then
ValueData = Left$(strData, InStr(1, strData, Chr$(0)) - 1)
End If
End If
Case REG_MULTI_SZ
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal 0, RetornoData)
If lResult = 0 Then
strData = String(RetornoData, Chr$(0))
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal strData, RetornoData)
If lResult = 0 Then
For i = Len(strData) To 1 Step -1
If Mid$(strData, i, 1) = Chr$(0) Then
strData = Left$(strData, i - 1)
Exit For
End If
Next
For i = 1 To Len(strData)
If Mid$(strData, i, 1) = Chr$(0) Then
Mid$(strData, i, 1) = " "
End If
Next
ValueData = Left$(strData, InStr(1, strData, Chr$(0)) - 1)
End If
End If
For i = Len(strData) To 1 Step -1
If Mid$(strData, i, 1) = Chr$(0) Then
strData = Left$(strData, i - 1)
Exit For
End If
Next
For i = 1 To Len(strData)
If Mid$(strData, i, 1) = Chr$(0) Then
Mid$(strData, i, 1) = " "
End If
Next
Case REG_BINARY
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal 0, RetornoData)
If lResult = 0 Then
ReDim binData(RetornoData)
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, binData(0), RetornoData)
If lResult = 0 Then
For i = 0 To UBound(binData) - 1
sTmp = sTmp & Right$("00" & Hex$(binData(i)), 2) & " "
Next
ValueData = sTmp
End If
End If
Case REG_DWORD, REG_DWORD_BIG_ENDIAN
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, lngData, RetornoData)
If lResult = 0 Then
ValueData = "0x" & Right$("00000000" & Hex$(lngData), 8) & " (" & lngData & ")"
End If
Case Else
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal 0, RetornoData)
If lResult = 0 Then
strData = String(RetornoData, Chr$(0))
lResult = RegQueryValueEx(Key, strValueName, 0, ByVal 0, ByVal strData, RetornoData)
If lResult = 0 Then
ValueData = Left$(strData, InStr(1, strData, Chr$(0)) - 1)
End If
End If
End Select
End Function
A la funcion se la llama con la clave ya abierta, si pueden ayudarme se lo agradeceria.
PD: ¿Como hacen para que el codigo salga con colores? Es menos lioso xD