Using Relative Path with Registry Key

tpra21

Active member
Joined
Oct 21, 2006
Messages
26
Programming Experience
1-3
I have a difficult question that I cannot find any information on. Say I want to get the current username value from the registry using the following code:

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] userRegKey [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] RegistryKey = Registry.CurrentUser
userRegKey = userRegKey.OpenSubKey([/SIZE][SIZE=2][COLOR=#800000]"Software\\Microsoft\\Active Setup\\Installed Components\\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] value1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2] = userRegKey.GetValue([/SIZE][SIZE=2][COLOR=#800000]"Username"[/COLOR][/SIZE][SIZE=2])
[/SIZE]

Now, how can I get the Username key value if I don't know the directory (Folder) names of the folders in the path. For example, if I don't know the name of the "Active Setup" folder in the path above, can I use the above path and plug a variable in.

Or, is there a function that can get me the registry key's path by using the key's (subkey's) name like "Username."

Thanks in advance, Adam
 
Not sure what you ask, but here's a few tries:

If you get partial path information from elsewhere you can add the strings up to the full path:
dim fullpath as string = "partpath" & pathinfovariable & "morepath"

If you want to employ different search methods you can use the RegistryKey methods GetSubKeyNames and GetValueNames

Each of what called "folder" in the path given is a RegistryKey if you didn't know.
 
The problem I have is a PDA is plugged into the PC. The PDA installs a documents folder on the PC. In the registry, it creates a path consisting of three folders and with registry key in the third folder. Example:

Registry key path:

Software\Windows CE\56af443d\

Then we have a registry key called "Briefcase Path" stored at the end of the above path. If I plug this PDA into a different PC, it creates the same path above, but the numeric directory (56af443d) changes to a different number. I need a way to programatically grab that directory name and store it in a variable, which I will then store in the file path declaration.

That way, everytime a user installs my software on a different PC and uses a different PDA (there are eight total that this company uses) to plug into it, the file path will not bomb.

Hope this is more clear.

Thanks, Adam
 
Back
Top