Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2003, 07:30 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Registry

Windows XP
Visual Basic (.NET)

Anyone know how to retrieve settings from HKEY_LOCAL_MACHINE (specifically the installation directory of Internet Explorer)

GetSetting only seems to retrieve settings from HKEY_USERS
 
Old November 3rd, 2003, 08:21 PM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Look in the .NET Framework Class Library >> Microsoft.Win32 >> Registry Class and RegistryKey Class.

Jim.

 
Old November 4th, 2003, 04:29 AM
Authorized User
 
Join Date: Jun 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jim

The getsetting was I think the vb6 way to read and write to the registry .Net offers much more flexability.

heres an example of reading and writing to the registry

'read connection string from registry
    Public Function GetConnectionString(ByVal strAppID As String) As String
        Const CompanyRegistryArea As String = "Insert Registry key(s) here."
        Dim strRegPath As String = CompanyRegistryArea & strAppID
        Dim RegTemp As RegistryKey

        RegTemp = Registry.LocalMachine.OpenSubKey(strRegPath, False)
        Return RegTemp.GetValue("ConnectionString", "").ToString
    End Function

    'write new connection string value to registry
    Public Sub SetConnectionString(ByVal strAppID As String, ByVal strNewValue As String)
        Const CompanyRegistryArea As String = "Insert Registry key(s) here."
        Dim strRegPath As String = CompanyRegistryArea & strAppID
        Dim RegTemp As RegistryKey

        RegTemp = Registry.LocalMachine.OpenSubKey(strRegPath, True)
        RegTemp.SetValue("ConnectionString", strNewValue)
    End Sub

Hope this helps

Duncan
 
Old November 4th, 2003, 04:32 AM
Authorized User
 
Join Date: Jun 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ooops! I should have addressed my last email to Jake and not Jim.

Duncan
 
Old November 5th, 2003, 05:18 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Duncan

I appreciate your help. One question though - presumably there's a user defined type - RegistryKey somewhere?

jake
 
Old November 6th, 2003, 04:02 AM
Authorized User
 
Join Date: Jun 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jake


Sorry about that, yes you need to import the following

Imports Microsoft.Win32




Duncan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Autoplay and Registry leopoldstotch VBScript 0 March 11th, 2007 12:00 PM
Registry Akmal Shah BOOK: Access 2003 VBA Programmer's Reference 1 May 25th, 2005 06:30 PM
Registry snowy0 VB.NET 2002/2003 Basics 1 September 8th, 2004 10:40 AM
Registry Information bmains ASP.NET 1.x and 2.0 Application Design 1 April 19th, 2004 03:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.