Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Read protected registry keys with vb6 using API or Activex control

Posted on 2009-07-10
12
Medium Priority
?
818 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 38

Accepted Solution

by:
PaulHews earned 2000 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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

886 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