Library code snippets

Read Registry values in VB without API

Often you'll want to manipulate the Windows registry in Visual
Basic without resorting to lengthy API calls. Fortunately you can
with the Registry Access Functions (RegObj.dll) library. This DLL
lets you create a Registry object with which you can manipulate
specific keys. For example, in a previous tip we showed you how
to use the WebBrowser control to display an animated GIF.

Unfortunately, the WebBrowser is only available if the target
machine also has Internet Explorer installed. As a result, you
may want to display an alternative image if Internet Explorer
isn't available. To determine if IE is installed on the target
Windows 95 machine, first set a reference in your project to
Registry Access Functions. Then use code similar to that below:

Dim myReg As New Registry, KeyFound As Boolean
Dim HasIE As Boolean, sValue As String
sValue = ""
KeyFound = myReg.GetKeyValue(HKEY_LOCAL_MACHINE, _
    "SoftwareMicrosoftWindowsCurrentVersion" & _
    "App PathsIEXPLORE.EXE", "Path", sValue)
If KeyFound Then HasIE = (sValue <> "")
If HasIE Then MsgBox sValue 'contains the path to IE

Set myReg = Nothing

Comments

  1. 26 Sep 2006 at 00:22

    i believe that this tutorial is actually in VB6 - it would appear you aren't using vb6... hopefully next time the author will make this clear

  2. 25 Feb 2004 at 11:26

    Just in case you guys were wondering where the heck this component is,
    try looking here:


    http://msdn.microsoft.com/vbasic/downloads/addins/components/default.aspx


  3. 20 Nov 2002 at 14:37

    works but not exactly as advertised. I needed to do the following


           Dim myReg As New RegObj.RegistryClass()
           Dim myregkey As RegObj.RegKey
           Dim mysubkey As RegObj.RegKey
           Dim myregvalue As RegObj.RegValue
           Dim sValue As String
           Dim KeyFound As Boolean


           Const HKM = RegObj.PredefinedHKeys.HKEYLOCALMACHINE
           sValue = ""


           myregkey = myReg.RegKeyFromHKey(HKM)
           myregkey = myregkey.ParseKeyName("SOFTWARE\ORACLE")
           For idx = 1 To myregkey.Values.Count
               If myregkey.Values.Item(idx).Name = "ORACLE_HOME" Then
                   sValue = myregkey.Values.Item(idx).Value
               End If
           Next

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Read Registry values in VB without API.

Leave a comment

Sign in or Join us (it's free).

ElementK Journals
AddThis

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!