Here is an example (with some debug info that you can leave out). It is now
restricted to String type entries. You must add the 'Windows Script Host
Object Model' to your references (via Tools => References)
Public Function ReadRegisteryKey(RKey As String) As String
Dim oKey As New IWshShell_Class ' Windows Script Host Object Model
library
Dim RKeyValue As String
Dim RegVal As Variant, Entry As Variant
On Error Resume Next
RegVal = oKey.RegRead(RKey)
If Not RegVal = Empty Then
If TypeName(RegVal) = "String" Then
RKeyValue = RegVal
'Else
' Debug.Print TypeName(RegVal)
' For Each Entry In RegVal
' Debug.Print Entry
' Next
End If
End If
If Err.Number <> 0 Then
'Debug.Print Err.Number & ": " & Err.Description
ReadRegisteryKey = vbNullString
Err.Clear
Else
ReadRegisteryKey = RKeyValue
End If
Set oKey = Nothing
End Function
Public Function WriteRegisteryKey(RKey As String, Value As Variant) As
Boolean
Dim oKey As New IWshShell_Class ' Windows Script Host Object Model
library
Dim RKeyValue As String
Dim RegVal As Variant, Entry As Variant
On Error Resume Next
Call oKey.RegWrite(RKey, Value)
If Err.Number <> 0 Then
'Debug.Print Err.Number & ": " & Err.Description
WriteRegisteryKey = False
Err.Clear
Else
WriteRegisteryKey = True
End If
Set oKey = Nothing
End Function
Try again with a back-slash at the end of your argument
You may also want to look at the standard MsAccess functions "GetSetting" en
"SaveSetting"
Vincent
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.