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:
Sponsor