Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2003-11-16
4
553 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 125 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

809 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