Ladda hem en Class fil (Registry) med färdiga funktioner. Hitta bättre funktioner på Tips & Triks som jag skall testa!!!WriteValue till registret?
Kan någon hjälpa mig hur men skriver in ex. en produkt nyckel (A987Z365XW1)
Och hämtar den och ta bort nyckeln?
Mycket taksam för hjälp!
<code>
'-----------------------------------------------------------------------------------------
Public Sub WriteValue(strValueName As String, strNewValue As String)
Dim lngReturn As Long
If Not m_blnSelected Then
Err.Raise vbObjectError + 2, "CRegistry:WriteValue", "No key is currently open."
Exit Sub
End If
lngReturn = RegSetValueEx(m_hCurrentKey, strValueName, 0&, REG_SZ, ByVal (strNewValue), Len(strNewValue))
If lngReturn <> ERROR_SUCCESS Then
Err.Raise vbObjectError + 2, "CRegistry:WriteValue", "Failed to write new value to " & strValueName & " from Registry."
Exit Sub
End If
End Sub
'----------------------------------------------------------------------------------------------
Public Function ReadValue(Optional strValueName As String = "") As String
Dim strBuffer As String
Dim lngLength As Long
Dim lngReturn As Long
If Not m_blnSelected Then
Err.Raise vbObjectError + 2, "CRegistry:ReadValue", "No key is currently open."
Exit Function
End If
strBuffer = Space(255)
lngLength = 255
lngReturn = RegQueryValueExString(m_hCurrentKey, strValueName, 0, 0, strBuffer, lngLength)
If lngReturn = ERROR_SUCCESS Then
ReadValue = Left(strBuffer, lngLength - 1)
Else
Err.Raise vbObjectError + 2, "CRegistry:ReadValue", "Failed to read value " & strValueName & " from Registry."
Exit Function
End If
End Function
'----------------------------------------------------------------------------------------------
Public Sub DeleteValue(strValueName As String)
Dim lngReturn As Long
If Not m_blnSelected Then
Err.Raise vbObjectError + 2, "CRegistry:DeleteValue", "No key is currently open."
Exit Sub
End If
lngReturn = RegDeleteValue(m_hCurrentKey, strValueName)
If lngReturn <> ERROR_SUCCESS Then
Err.Raise vbObjectError + 2, "CRegistry:DeleteValue", "Failed to delete value " & strValueName & " from Registry."
Exit Sub
End If
End Sub
</code>Sv: WriteValue till registret?
Tack!
/Per