Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

Common Language Runtime How to search specific byte pattern (string) in reg_binary from r...

by the3factory 4/7/2008 6:05:00 AM
Common Language Runtime How to search specific byte pattern (string) in reg_binary from r...
Question:
've a reg_binary key called fooKey in the registry, and I would like to search if '0x57 0x49' (i.e. "WI") is in the fooKey, how to do it in C#? 

 

Thanks.

 

Answer1:

RegistryKey reg = Registry.LocalMachine; // (could also be something else here, like CurrentUser for instance , depending on where you put your key.).

 

// drill down through your registry values:

 

reg = reg.OpenSubKey("SYSTEM");

reg = reg.OpenSubKey("CurrentControlSet");

reg = reg.OpenSubKey("Control");

reg = reg.OpenSubKey("COM Name Arbiter");

 

// get your value

byte[] value = reg.GetValue("fooKey");

 

// iterate through your value and find the result.

foreach (byte b in value)

if (b == 0x59)

return true;

 

return false;

 




David Morton - Consultant - Catapult Systems - Houston
Answer2:

 

Thanks, David.

 

Is there an existing method to deal with sequence of byte pattern? e.g. "FOOTEST" (in string representation)

 

Or do I have to examine the pattern one by one?

 

Thanks.

Answer3:

That's what the encoding class is for:

 

Code Snippet

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0