Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-16
4
Medium Priority
?
585 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
ID: 9762104
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
ID: 9762992

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
ID: 9773491
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 500 total points
ID: 9776976

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

876 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