CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 1999
    Location
    Latvia, Riga
    Posts
    36

    trouble with registry

    i wanna get data from registry, so i write this:

    strRegData = GetSetting(HKEY_CURRENT_CONFIG \ Display, Settings, BitsPerPixel)

    ...and get division by zero. where is bug?
    thanks, ToXa.


  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: trouble with registry

    Try

    strRegData = GetSetting(HKEY_CURRENT_CONFIG +"\ Display", Settings, BitsPerPixel)



  3. #3
    Join Date
    Apr 1999
    Location
    Latvia, Riga
    Posts
    36

    i try another...[inside]

    i try this:

    strRegData = GetSetting("HKEY_CURRENT_CONFIG\Display", "Settings", "Resolution", "zero")

    ...its work without error message, but write in strRegData a "zero", BUT IN MY REGISTRY THE RESOLUTION VALUE PRESENT!
    where is bug?



  4. #4
    Join Date
    Dec 1999
    Posts
    128

    Re: i try another...[inside]

    The "root" branch for GetSetting() function is the following:

    HKEY_CURRENT_USER\Software\VB and VBA Program Settings\

    That means that you cannot access branches above this. In order to do that, you have to use API functions (open registry, retrieve registry value and then close registry). There are controls and dlls that do this in an "automatic" way, similar to GetSetting. I believe if you search a little bit, you'll find some code (i think there was a control called easyreg...)


    Nick A.
    -------------------------
    Nick A.

  5. #5
    Join Date
    Apr 1999
    Location
    Latvia, Riga
    Posts
    36

    not working...[inside]

    ok, i wanna to get data from:

    HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Time Thingy\Setup

    Interval - it's value is 5

    so i type:

    strRegData=GetSeting("HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Time Thingy", "Setup", "Interval", "Zero")

    ..and get "Zero" - may be it something wrong with my PC?


  6. #6
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329

    Some Registry Samples

    http://www.planet-source-code.com/xq...s/ShowCode.htm

    http://www.planet-source-code.com/xq...s/ShowCode.htm

    http://www.planet-source-code.com/xq...s/ShowCode.htm

    http://www.planet-source-code.com/xq...s/ShowCode.htm

    http://www.netfokus.dk/vbadmincode/c...ctregistry.zip

    http://vbaccelerator.com/codelib/inireg/registry.htm

    Or alternatively if you don't need all the enumeration functions and know the specific keys you need to read/write you can use the WSH (Windows Scripting Host) in this way:


    private Sub Command1_Click()
    Dim wshShell as Object
    set wshShell = CreateObject("WScript.Shell")
    With wshShell
    MsgBox .RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName")
    End With
    End Sub




    Or if you add a reference to Windows Script Host Model to the project you can declare wshShell As IWshShell and you can access the properties in the usual way.

    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  7. #7
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329

    Re: not working...[inside]

    You don't need to specify the full path of the key when using GetSetting:

    strRegData=GetSeting("HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Time Thingy", "Setup", "Interval", "Zero")

    Should be specified as

    strRegData=GetSetting("Time Thingy", "Setup", "Interval", 0)

    As the default value is an integer should be specified as an integer.

    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  8. #8
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329

    Re: not working...[inside]

    Sorry that should read:

    Dim intRegData As Integer

    intRegData=GetSeting("Time Thingy", "Setup", "Interval", 0)

    Instead of strRegData.

    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  9. #9
    Join Date
    Apr 1999
    Location
    Latvia, Riga
    Posts
    36

    great thanx - IT WORKING!!!

    ))


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured