Solved

using the registrykey command (as opposed to the getallsettings command)

Posted on 2003-11-16
4
543 Views
Last Modified: 2012-06-27
as most people know (and i just found out), the getallsettings command in access VB is limited to the vb settings folder of the hkey_current_user portion of the registry.

here's the code i *was* using:

---
    Dim MySettings As Variant, intSettings As Integer, copyprotect As String

    ' Check registry settings
    MySettings = GetAllSettings(appname:="MyProgram", section:="Startup")
    For intSettings = LBound(MySettings, 1) To UBound(MySettings, 1)
        If intSettings = 0 Then
            If MySettings(intSettings, 0) = "Right" And MySettings(intSettings, 1) = "5" Then
                copyprotect1 = "okay"
            End If
        ElseIf intSettings = 1 Then
            If MySettings(intSettings, 0) = "Bottom" And MySettings(intSettings, 1) = "7" Then
                copyprotect2 = "okay"
            End If
        End If
    Next intSettings
---

my problem is that i need to be able to read settings from the hkey_local_machine portion of the registry.  after reading about the .net framework on the msdn site, i'm confused regarding the proper use of the registrykey command.

can anyone help me do what i was doing before now that i'm playing with what seems to be a totally different command?

(i'm using access 2000, if that makes any difference.)

thanx!
danielle
www.brownflower.com/danielletx
0
Comment
Question by:danielletx
  • 2
4 Comments
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
There are some examples of reading registry entries here
http://www.mvps.org/access/api/api0015.htm

Pete
0
 
LVL 4

Expert Comment

by:inox
Comment Utility

you can use

    Dim objWSH As Object    
    Set objWSH = CreateObject("WScript.Shell")

e.g.    objWSH.RegWrite "HKLM\Software\MyApplication\strValue",
"Some string value"

objWSH.RegWrite "HKLM\Software\MyApplication\key1", 1234, "REG_DWORD"

0
 

Author Comment

by:danielletx
Comment Utility
i REALLY like the elegance and brevity of inox's comment.  the only problem is that the objWSH.RegWrite command actually *writes* a value to the registry rather than reading it.

i tried to use objWSH.RegRead, and i get an error.

is there some way to use the whol objWSH thing that will look for the path that i specified in my question...?

sorry.  i'm a little dense when it comes to VB, and so i have a hard time making even tiny little logical leaps.

thanx so much for all the help everyone has offered!  :)
danielle
http://www.brownflower.com/danielletx
0
 
LVL 4

Accepted Solution

by:
inox earned 125 total points
Comment Utility

danielle,
of course the objWSH ("WScript.Shell") can read values from registry, can you post your commands
or verify to be like

  Dim objWSH As Object
  Set objWSH = CreateObject("WScript.Shell")
  objWSH.RegWrite "HKCU\Software\VB and VBA Program Settings\App1\Sect1\DW1", 123, "REG_DWORD"
  L = objWSH.RegRead("HKCU\Software\VB and VBA Program Settings\App1\Sect1\DW1")
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now