Obtaining multiple values from registry

R

Roy Lasris

I want to determine the names of users on a particular computer that are using
Word. I have discovered that about the only place one might look is in:

"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Doc
FolderPaths"

I can obtain the value of a known user (let's say me, Roy) by this formula

aName = System.PrivateProfileString("", _
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Doc
FolderPaths", "Roy")

(the above actually gives me much more than I need--its the full path to the
MyDocs folder under my settings, but I can parse the extraneous stuff out.)

I would like to know if there is a routine that would identify each of the
users in that registry item, something along the lines of:

For Each oUser in Registry
aName = System.PrivateProfileString("", _
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Doc
FolderPaths", oUser)

Any ideas as to how this might be done would be greatly appreciated.
Thanks.

Roy
 
S

Steve Yandl

Roy,

If the computer(s) in question runs Win2000, WinME or WinXP, you can take
advantage of WMI. The following subroutine would extract each of the name
values and corresponding path string.

Sub GetAllUsers()

Const HKEY_LOCAL_MACHINE = &H80000002

Dim strComputer As String
Dim strKeyPath As String
Dim oReg As Object

Dim strOutput

strComputer = "."
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion"
strKeyPath = strKeyPath & "\Explorer\DocFolderPaths"

Set oReg = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\default:StdRegProv")

oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes

For i = 0 To UBound(arrValueNames)
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames(i),
strValue
strOutput = strOutput & arrValueNames(i) & " " & strValue & vbCrLf
Next

MsgBox strOutput
End Sub


Steve
 
S

Steve Yandl

Note that the Set oReg should be two lines and not three. I should have
made adjustments before pasting.
 
R

Roy Lasris

Steve,

Works great. I'm still trying to determine what it is doing, but at least I
get what I am looking for. Thanks so much.

Roy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top