Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read protected registry keys with vb6 using API or Activex control

Posted on 2009-07-10
12
Medium Priority
?
816 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses

705 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