Results 1 to 6 of 6

Thread: [RESOLVED] Reading hex keys from registry.

  1. #1

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Resolved [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.
    My Blog.

    Ryan Jones.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  3. #3

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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?
    My Blog.

    Ryan Jones.

  4. #4
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    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);

  5. #5

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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
    My Blog.

    Ryan Jones.

  6. #6
    New Member
    Join Date
    Oct 2013
    Posts
    1

    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
  •  



Click Here to Expand Forum to Full Width