-
Dec 26th, 2009, 05:17 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Reading hex keys from registry.
Hi guys!
I wonder if anyone could help me out with this one. I've figured out that the normal.dot path is stored in the register under
Code:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\Options
in a key called STARTUP-PATH. If it's not set then the default location is simple enough to get.
The issue is, is that the key is hex encoded and I am unsure how to decode this type of registry key so any assistance would be welcomed.
-
Dec 26th, 2009, 11:17 AM
#2
Re: Reading hex keys from registry.
I don't have that key on my system so I can't see exactly what you mean. Exactly what is the type of the reg value? If it's REG_BINARY then the value is not hex encoded at all, but rather that is just how it's displayed in RegEdit. It's actually binary data, so it will be retrieved as a Byte array. Exactly how to process that depends on exactly what it represents. If it's supposed to be a file path then I guess you'd want to convert it to text, which you would do by calling GetString on the appropriate Encoding object, e.g. Encoding.ASCII or Encoding.Unicode. You could try a few until you find the right one.
-
Dec 26th, 2009, 06:49 PM
#3
Thread Starter
Frenzied Member
Re: Reading hex keys from registry.
Well. The key looks like this when exported from the registry editor:
Code:
[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\Options]
"STARTUP-PATH"=hex(2):44,00,3a,00,5c,00,4d,00,53,00,20,00,4f,00,66,00,66,00,69,\
00,63,00,65,00,5c,00,53,00,74,00,61,00,72,00,74,00,75,00,70,00,5c,00,00,00
Does that help at all? I'm guessing I can just use the regular |RegistryKey.GetValue| and then use ToString() on it to get the path?
-
Dec 29th, 2009, 01:31 PM
#4
Re: Reading hex keys from registry.
That is simply a hexadecimal string. The '00' values are meaningless. Run this and see what happens:
Code:
String regValue= "hex(2):44,00,3a,00,5c,00,4d,00,53,00,20,00,4f,00,66,00,66,00,69,00,63,00,65,00,5c,00,53,00,74,00,61,00,72,00,74,00,75,00,70,00,5c,00,00,00";
String dirPath = String.Empty;
foreach (String hex in regValue.Split(':')[1].Split(','))
if (!hex.Equals("00"))
dirPath += (char)Convert.ToInt32(hex, 16);
MessageBox.Show(dirPath);
-
Dec 31st, 2009, 07:48 AM
#5
Thread Starter
Frenzied Member
Re: Reading hex keys from registry.
It turns out that my original idea was correct, it looks like toString works fine! Thanks for the ideas guys
-
Oct 18th, 2013, 07:15 AM
#6
New Member
Re: Reading hex keys from registry.
Reading hex EncPassword C#?
"User"=hex(0):6b,65,73,61,63,68,69,74,00
"EncPassword"=hex(0):6b,60,7b,6e,61,7f,67,7a,60,61,68,61,6e,62,00
thank.!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|