Results 1 to 11 of 11

Thread: Check Byte data of a registry value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Location
    VietNam
    Posts
    81

    Check Byte data of a registry value


    How to check the data inside this value anyone ?

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

    Re: Check Byte data of a registry value

    You would call My.Computer.Registry.GetValue, specifying the key and value names, and assign the result to a variable whose type is Byte(), i.e. Byte array. You can then test each individual element of that Byte array.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Location
    VietNam
    Posts
    81

    Re: Check Byte data of a registry value

    Unfortunately, i understand your solution but i know almost nothing about VB.NET, so can you please give me a bit more details

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Check Byte data of a registry value

    You know that you need to use My.Computer.Registry.GetValue. When you searched for that on the web and in the MSDN documentation, what examples did you find? Did any of them include use of a Byte array?

    http://www.google.com.au/search?q=my...ient=firefox-a

    First result:

    http://www.java2s.com/Tutorial/VB/04...ryGetValue.htm

    Demonstrates how to retrieve data from the Registry and how to use a Byte array so retrieved. You don't need any programming experience to search the web. If you have no idea where to start, which may have been the case when you first posted, obviously you can't search. Once someone provides you with the keywords, the first thing you should be doing is searching for those keywords. Whatever it is that you want to do, there's most likely already examples out there. If you know what to search for, e.g. type names, method names, etc, then finding those existing examples is usually fairly easy.
    Last edited by jmcilhinney; Feb 19th, 2010 at 09:53 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Check byte data in a registry value

    Please do not start a new thread when you already have a thread for this question. Not only do you already have a thread for this question, you already have an answer. You say that you don't know how yet in your other thread I provided a link that contains code that shows how to do it. Have you read that code and made an effort to write some code for yourself?

    http://www.vbforums.com/showthread.php?t=603978
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Location
    VietNam
    Posts
    81

    Re: Check byte data in a registry value

    vb Code:
    1. Option Strict On
    2.  
    3. Public Module RegistryTest
    4.    Public Sub Main()
    5.       Dim data As Object
    6.       data = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\wrifile\DefaultIcon", _
    7.                                             String.Empty, String.Empty)
    8.  
    9.       If TypeOf data Is String Then
    10.          Console.WriteLine("String data: " & data.ToString())
    11.       ElseIf TypeOf data Is Integer Then
    12.          Console.WriteLine("Integer data: " & CInt(data))
    13.       ElseIf TypeOf data Is String() Then
    14.          Console.WriteLine("String array: ")
    15.          Dim dataArray() As String = DirectCast(data, String())
    16.          For ctr As Integer = LBound(dataArray, 1) To UBound(dataArray, 1)
    17.             Console.WriteLine(" " & dataArray(ctr))
    18.          Next
    19.       ElseIf typeOf data Is Byte() Then
    20.          Console.WriteLine("Binary data: ")
    21.          Dim byteArray() As Byte = DirectCast(data, Byte())
    22.          For ctr As Integer = LBound(byteArray, 1) To UBound(byteArray, 1)
    23.             Console.Write(" " & Hex(byteArray(ctr)) & " ")
    24.          Next
    25.       Else
    26.          Console.WriteLine("Unknown data type...")
    27.       End If
    28.    End Sub
    29. End Module


    Sorry for the inconvenience , but can you please give me an detail example

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Check byte data in a registry value

    What is that code if not a detailed example? Exactly what is it about the information you already have that you don't understand? I said that you should use My.Computer.Registry.GetValue to get the data from the Registry as a Byte array, then you can examine the contents of that Byte array. That code does exactly that. It handles other data types too but you can simply ignore the parts that you don't need.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Location
    VietNam
    Posts
    81

    Re: Check byte data in a registry value

    i created a windows form with a checkbox to check data of a value inside registry key.I had code to check string,dword data however i had no idea how to check byte data. You told me to use My.computer.Registry.Getvalue but to tell the truth i don't know anything, just someone give me the code my job is to copy and edit the name,key, value etc...

    So can you show me the code to check if a value contains exact byte data as i expect the checkbox will show a check, if not nothing is showed

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VS 2008 Check byte data in a registry value

    So basically you already know how to get data from the Registry because you're already doing it. If that's the case, why did you not say so? You're asking us to show you something that you already know how to do. Your only problem is checking the values of the elements in a Byte array, which has nothing to do with the Registry. A Byte array is a Byte array. Where it came from is irrelevant.

    So, do you know how to get an element from an array? If not, look at the code you just posted. It does it twice, in the string array and byte array sections. What are the elements of a Byte array? By definition, they are Bytes. So, what do you have to do to test the contents of a Byte array? You would probably first test its Length. If the number of Bytes in the array is not correct then the whole thing can't possibly be correct. Assuming the Length is correct, you then simply test each element. You know how to get an element from an array because its in the code you yourself posted. Just get each element and test it against the expected value. If one doesn't match then the whole lot doesn't match.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Location
    VietNam
    Posts
    81

    Re: VS 2008 Check byte data in a registry value

    thanks i'll check it out

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Check Byte data of a registry value

    Please do not create duplicate threads. It is not an accepted practice on our Forums.

    Duplicate Thread Merged

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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