Solved

Read protected registry keys with vb6 using API or Activex control

Posted on 2009-07-10
12
807 Views
Last Modified: 2013-11-18
Need to read this key and its subkeys, but have not been able to.  Using VB6, tried using API calls, and several registry management activex controls.  Nothing seems to work.  Here's the key I'm trying to get to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR

I can read up to ...\ControlSet and some of its subkeys, but can't read ...\Enum  or ...\Enum\USBSTOR.  I only want to read these keys and subkeys, do not want to change anything.  Can read all of them no problem with regedit, but I need to do this with my program, on the users computer with could be xp up.

If there is a VB6 activex that does this, I have no problem paying for it.  The only one I've found  that *might* work is from Eltima Software:
http://www.eltima.com/products/registry-activex/
...which has a read key parameter they claim takes the R/O flag, but I can't get it to work, and tech support from this overseas company only gets me a sales rep who can't do more than ask dumb obvious questions, with 24+ hr turnaround.

Is this solvable?
0
Comment
Question by:xbeemer
  • 5
  • 3
  • 2
12 Comments
 
LVL 29

Expert Comment

by:matrixnz
ID: 24830330
The following works for me fine
const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

 

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 

strComputer & "\root\default:StdRegProv")

 

strKeyPath = "SYSTEM\CurrentControlSet\Enum\USBSTOR"

oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

 

For Each subkey In arrSubKeys

    WScript.Echo subkey

Next

Open in new window

0
 

Author Comment

by:xbeemer
ID: 24830862
Thanks for the reply....but I don't get it.  Could you, as they say at the spelling bee, use it in a sentence?  Maybe wrap it in a

Private Sub Command1_Click()

End Sub

...and especially indicate what the Set GetObject refers to?  My VB6 IDE thinks it should be printed in red.
0
 

Author Comment

by:xbeemer
ID: 24887478
I responded to this a week ago, asking for clarification.  Still no response from the "experts."  Or anyone else (I also emailed support).  This looked like a good service at first, well worth the subscription price.  But the lack of response to the one and only issue I requested help on (and assigned my max points to), leaves me feeling Experts Exchange is all hat and no cattle.
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 24907112
The reason the code posted above looks alien is because it's VBScript, not Visual Basic 6.  Here's the same code with suitable declarations so that it compiles and runs in VB6.  
Option Explicit
 

Private Sub Command1_Click()

    Const HKEY_LOCAL_MACHINE = &H80000002

    Dim strComputer As String

    Dim strKeyPath As String

    Dim oReg As Object

    Dim arrSubKeys As Variant

    Dim SubKey As Variant

    

    strComputer = "."

    

 

    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _

    strComputer & "\root\default:StdRegProv")

 

    strKeyPath = "SYSTEM\CurrentControlSet\Enum\USBSTOR"

    oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

 

    For Each SubKey In arrSubKeys

        Debug.Print SubKey

    Next
 

End Sub

Open in new window

0
 

Author Closing Comment

by:xbeemer
ID: 31602327
That worked.  Thanks much!
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 38

Expert Comment

by:PaulHews
ID: 24907364
>That worked. Thanks much!

You're welcome.  I think it would have been more appropriate to split the points (as I was elaborating on the other expert's code.)  I will request this from the moderator team.  
0
 

Author Comment

by:xbeemer
ID: 24907415
Maybe, if he had responded to my message requesting clarification over a week ago.  I was about to bail, thinking this was a rip off service.  The other expert did no one any good.
jd
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 24907882
>The other expert did no one any good.

Well, the other expert provided the code.  My alterations were very minor.  As to why the expert never followed up, well there could be many good reasons for that.   We are all volunteers here, and real life takes priority.

The other expert took the time to research, test the code (it would work in VBScript) and post it.  My feeling is that that contribution should be recognized, even if he didn't stick around to follow up.
0
 

Author Comment

by:xbeemer
ID: 24908500
OK.  I disagree, but it's your call.  Do as you like.  And thanks again for the help.
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 24908607
Sorry for not following up, we're in the middle of a merger at work so don't have as much time as I had in the past.  To be honest I actually didn't see you had responded, may of accidentally deleted the response message.  Anyway I'm happy for the points to stay with Paul, glad it's sorted, thanks Paul you're a scholar and a gentleman. =)

Cheers
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now