CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2010
    Posts
    3

    Question reading registry

    Hello,

    I'm trying to make a command button that starts application that has it's
    relative location written in registry (HKLM\SOFTWARE\Wow6432Node\...\DirIns,
    DirIns being REG_SZ).

    Anyone kind enough to provide proper code?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: reading registry

    That would require ADMINISTRATIVE permission, and you can't program that, if that's your question. Is that Windows 7, or Vista?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2010
    Posts
    3

    Re: reading registry

    Well, I'm using XP64 but I don't see why would reading a registry key require admin rights
    or be OS dependant (apart from addition of 'wow6432node' in 64bit OS).

    Basically what I'm trying to read out from registry is the installation path written by setup
    from a string value, which I'd then append in ShellExecute or Shell command - something
    like:

    whatimlookingfor = path as string
    Shell("path\*.exe")

    Is that doable?

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: reading registry

    It should be.
    Look at this page http://allapi.mentalis.org/apilist/r.shtml
    Read the RegOpenKeyEx() and RegQueryValueEx() descriptions. Look at the sample how you read a registry key.

    Another idea is to use the scripting host:
    Code:
      Dim wsh As Object
      Dim Result as String
      Set wsh = CreateObject("WScript.Shell")
      Result =  wsh.RegRead(KeyString)
    KeyString must be the full registry path to the desired value.
    If this is a valid file path you can Shell Result & "\filename.exe"

    But David might be right with the administrative permissions. I'm not sure, I'm always administrator on my computers.
    Last edited by WoF; January 29th, 2010 at 07:59 AM.

  5. #5
    Join Date
    Jan 2010
    Posts
    3

    Re: reading registry

    Thanks alot WoF!

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: reading registry

    Powershell 2.0 is the call for DOS-like Scripting on XP+ systems

    http://technet.microsoft.com/en-us/s.../dd742419.aspx
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured