Reading Registry Keys - Bug or Mistake?

Discussion in 'Questions (Windows Mobile)' started by Raytracer, Apr 18, 2008.

  1. Raytracer

    Raytracer Member Licensed User

    I have written these lines:

    Sub Globals
    'Declare the global variables here.
    Dim number, name, files(0) As string, binary(0) As byte
    End Sub

    Sub App_Start
    number = reg.GetValue("Software\OEM", "SysLang") 'Number Of Items is of type REG_DWORD
    name = reg.GetValue("Software\Comm", "AutoRun") 'User Name is of type REG_SZ
    files() = reg.GetValue("Software\Drivers\BuiltIn", "IClass") 'Recent file is of type REG_MULTI_SZ (multi - string)
    binary() = reg.GetValue("Software\AudioCompressionManager\Dri verCache\msacm.msg711","aFormatTagCache") 'BinaryValue is of type REG_BINARY

    Msgbox(number, "DWORD")
    Msgbox(name, "STRING")
    Msgbox(files(), "MULTISTRING")
    Msgbox(binary(), "BINARY")

    End Sub

    It comes given back the error to me of “key not found” on the reading of the DWORD; if I try to exclude the line, same thing for the STRING.
    The stranger thing is that I have copied equal par the example of the Handbook; the only variation has been carried out on the path of the variable ones of the registry to read.
    I have used one similar sintax in order to read keys on HKCU (rather than HKLM) without problems of risen… it is a bug or mistake something?
    Thanks to anyone want to answer to me
  2. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that these keys really exist?
    Some tips:
    - It is better to use GetString, GetInt and the other Get methods instead of the general GetValue.
    - There is no meaning to Msgbox(files()). files() is an array and it can't be implicitly converted to string.