VS 2008 Might be simple, Might be hard: Reg_Binary-VBForums
Results 1 to 11 of 11

Thread: Might be simple, Might be hard: Reg_Binary

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    79

    Cool Might be simple, Might be hard: Reg_Binary

    I'm stuck at the moment gents, and would like to ask for your help.

    I have a registry value (reg_binary): B7 59 C4 4A
    I know that this value contains a Date and a Time, you guessed it

    How to convert?

    I'm reading the value like this:
    Code:
    Dim ActiveSince() As Byte = Nothing
    ActiveSince = My.Computer.Registry.LocalMachine.OpenSubKey("Software\MyApp\Version").GetValue("ActiveSince")
    I'm not asking a lot of times here as almost everything is to be found when one searches carefully, at the moment I can't find it.
    Your help would be appreciated a lot by me.

    Kind Regards, Starf0x

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,941

    Re: Might be simple, Might be hard: Reg_Binary

    Have you tried DateTime.TryParse?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    79

    Re: Might be simple, Might be hard: Reg_Binary

    Thank you for your response.

    The TryParse won't and can't work with a Byte Array.

    I just tried on your advise

    Starf0x

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Might be simple, Might be hard: Reg_Binary

    Do you know how this date was written to the registry in the first place? Also, do you know what date it actually represents? Does it represent just a date or is it a date and a time?

    I've never tried this before but just had a quick go and not getting very far... All I can do at the moment is return an Integer representation but I dont know if it is even anything like the actual date - I'm assuming it is though because it has 2007 at the end and it seems like too much of a coincidence that it would have a recent year at the end of it..

    vb Code:
    1. MessageBox.Show(BitConverter.ToInt32(DATE_BYTE_ARRAY_HERE, 0).ToString)
    That gives me 1254382007 which I suppose could represent 12:54 on the 3rd day of the 8th month of 2007 but that is just a big guess at the moment.

    The Date type does actually have a method named FromBinary which looks promising but the problem is it only works with a Long value (aka Int64) but when I try and do BitConverter.ToInt64 and pass in your byte array it basically tells me that the array is not long enough. Which is why I am wondering if your date is just a date and not a date and a time... but I dont know.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    79

    Lightbulb Re: Might be simple, Might be hard: Reg_Binary

    I can give you some examples;

    B7 59 C4 4a = Thu Oct 01 09:26:47 2009
    19 EC 9C 4a = Tue Sep 01 11:40:41 2009
    4F 55 BE 4A = Sat Sep 26 19:54:23 2009
    17 B8 C5 47 = Wed Feb 27 20:20:55 2009

    These are actual examples, bit strange layout, but hey I didn't invent this :P

    Starf0x

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,941

    Re: Might be simple, Might be hard: Reg_Binary

    How were you able to determine the dates from those values? BTW, Feb. 27, 2009 if Friday. =)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    79

    Re: Might be simple, Might be hard: Reg_Binary

    Another program shows those values, and it also reads these values.

    Kind Regards, Starf0x

    PS, I think that was a typo

  8. #8
    Fanatic Member
    Join Date
    Aug 2009
    Posts
    540

    Re: Might be simple, Might be hard: Reg_Binary

    you can't look at the source code of the other program?
    Where I'm from we only have one bit of advice for new comers: "If you hear banjos, turn and run".


    VS 2008 .NetFW 2.0

  9. #9
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Might be simple, Might be hard: Reg_Binary

    You need to also consider the fact it could be encrypted data.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  10. #10
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Might be simple, Might be hard: Reg_Binary

    You need to also consider the fact it could be encrypted data.
    Thats a good point - there doesnt seem to be any logical mapping to any .NET date/time type from that hex string.
    Do you know if this other program was written in .NET code?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    79

    Re: Might be simple, Might be hard: Reg_Binary

    Nah, it is not written in .NET, else I would be able to do this

    Seems to be a hard thing to crack?

    Kind Regards, Starf0x

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.