How to check the data inside this value anyone ?
Printable View
How to check the data inside this value anyone ?
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.
Unfortunately, i understand your solution but i know almost nothing about VB.NET, so can you please give me a bit more details
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.
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
vb Code:
Option Strict On Public Module RegistryTest Public Sub Main() Dim data As Object data = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\wrifile\DefaultIcon", _ String.Empty, String.Empty) If TypeOf data Is String Then Console.WriteLine("String data: " & data.ToString()) ElseIf TypeOf data Is Integer Then Console.WriteLine("Integer data: " & CInt(data)) ElseIf TypeOf data Is String() Then Console.WriteLine("String array: ") Dim dataArray() As String = DirectCast(data, String()) For ctr As Integer = LBound(dataArray, 1) To UBound(dataArray, 1) Console.WriteLine(" " & dataArray(ctr)) Next ElseIf typeOf data Is Byte() Then Console.WriteLine("Binary data: ") Dim byteArray() As Byte = DirectCast(data, Byte()) For ctr As Integer = LBound(byteArray, 1) To UBound(byteArray, 1) Console.Write(" " & Hex(byteArray(ctr)) & " ") Next Else Console.WriteLine("Unknown data type...") End If End Sub End Module
Sorry for the inconvenience , but can you please give me an detail example
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.
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
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.
thanks i'll check it out
Please do not create duplicate threads. It is not an accepted practice on our Forums.
Duplicate Thread Merged