Op http://www.freevbcode.com/ShowCode.Asp?ID=4487 vond ik een script dat een key uit het registry moet halen.
Maar ik krijg altijd de foutmelding "Comma or ")" expected" in
OptionalByRef ErrInfo As String = "") As String
Is dit een fout in het script of ligt de fout bij mij
Ik heb al van alles geprobeert, maar ik vind de juiste oplossing niet.
Is er trouwens geen compactere manier? (met een eigen commando ofzo?)
code:
1
| Imports Microsoft.Win32 |
code:
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| Public Function RegValue(ByVal Hive As RegistryHive, _
ByVal Key As String, ByVal ValueName As String, _
OptionalByRef ErrInfo As String = "") As String
'DEMO USAGE
'Dim sAns As String
'Dim sErr As String = ""
'sAns = RegValue(RegistryHive.LocalMachine, _
' "SOFTWARE\Microsoft\Windows\CurrentVersion", _
' "ProgramFilesDir", sErr)
'If sAns <> "" Then
' Debug.WriteLine("Value = " & sAns)
'Else
' Debug.WriteLine("This error occurred: " & sErr)
'End If
Dim objParent As RegistryKey
Dim objSubkey As RegistryKey
Dim sAns As String
Select Case Hive
Case RegistryHive.ClassesRoot
objParent = Registry.ClassesRoot
Case RegistryHive.CurrentConfig
objParent = Registry.CurrentConfig
Case RegistryHive.CurrentUser
objParent = Registry.CurrentUser
Case RegistryHive.DynData
objParent = Registry.DynData
Case RegistryHive.LocalMachine
objParent = Registry.LocalMachine
Case RegistryHive.PerformanceData
objParent = Registry.PerformanceData
Case RegistryHive.Users
objParent = Registry.Users
End Select
Try
objSubkey = objParent.OpenSubKey(Key)
'if can't be found, object is not initialized
If Not objSubkey Is Nothing Then
sAns = (objSubkey.GetValue(ValueName))
End If
Catch ex As Exception
ErrInfo = ex.Message
Finally
'if no error but value is empty, populate errinfo
If ErrInfo = "" And sAns = "" Then
ErrInfo = _
"No value found for requested registry key"
End If
End Try
Return sAns
End Function |
Maar ik krijg altijd de foutmelding "Comma or ")" expected" in
OptionalByRef ErrInfo As String = "") As String
Is dit een fout in het script of ligt de fout bij mij
Ik heb al van alles geprobeert, maar ik vind de juiste oplossing niet.
Is er trouwens geen compactere manier? (met een eigen commando ofzo?)
[ Voor 9% gewijzigd door The Dud3 op 21-02-2003 20:09 ]
The opinions stated in the above post are purely those of the author,
and do not represent intelligent life of any form.