[VB.NET]Script werkt niet

Pagina: 1
Acties:
  • 37 views sinds 30-01-2008

  • The Dud3
  • Registratie: Maart 2002
  • Laatst online: 10-07 15:18
Op http://www.freevbcode.com/ShowCode.Asp?ID=4487 vond ik een script dat een key uit het registry moet halen.
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.


  • The Dud3
  • Registratie: Maart 2002
  • Laatst online: 10-07 15:18
Iemand?

The opinions stated in the above post are purely those of the author,
and do not represent intelligent life of any form.


  • Gerco
  • Registratie: Mei 2000
  • Laatst online: 18-08 22:57

Gerco

Professional Newbie

Misschien een spatie tussen Optional en ByRef :X

Het is hier trouwens niet de gewoonte dit soort topics te posten en al helemaal niet om ze binnen 24 uur omhoog te schoppen. Lees de FAQ even als je wilt.

[ Voor 60% gewijzigd door Gerco op 21-02-2003 21:12 ]

- "Als ik zou willen dat je het begreep, legde ik het wel beter uit!" | All number systems are base 10!


  • The Dud3
  • Registratie: Maart 2002
  • Laatst online: 10-07 15:18
Gerco schreef op 21 februari 2003 @ 21:10:
Misschien een spatie tussen Optional en ByRef :X

Het is hier trouwens niet de gewoonte dit soort topics te posten en al helemaal niet om ze binnen 24 uur omhoog te schoppen. Lees de FAQ even als je wilt.
Neen, dat help niet.
Dan krijg ik "Statement is not valid in a namespace." :(

[ Voor 8% gewijzigd door The Dud3 op 21-02-2003 21:37 ]

The opinions stated in the above post are purely those of the author,
and do not represent intelligent life of any form.


  • dusty
  • Registratie: Mei 2000
  • Laatst online: 21-02 00:06

dusty

Celebrate Life!

The_Dud3 : Friday 21 February 2003 19:58
The_Dud3 : Friday 21 February 2003 20:57


Zo snel kicken is niet toegestaan,

Bovendien ziet dit er teveel uit als een script request - " Ik heb een source gevonden, maar het werkt niet wat is er fout?".

Ik zie niets terug in welke regel de fout voorkomt, ik zie niets van wat je al heb proberen te doen. Ik zie alleen maar dat jij een script hebt gevonden, dat het niet werkt, en dat jij verwacht dat we je probleem oplossen.

Sorry.

Back In Black!
"Je moet haar alleen aan de ketting leggen" - MueR


Dit topic is gesloten.