- 1). Open Visual Studio and the file you intend to use to access the registry. Type "Microsoft.Win32" so the compiler recognizes the registry classes you'll use in your code.
- 2). Instantiate a RegistryKey variable using the binary registry value you need to convert:
RegistryKey sampleRegistryKey = //access appropriate registry file here. - 3). Convert the registry value into the binary data type and place it in an array of bytes:
byte[] sampleBytesFromRegistery = (byte()) sampleRegistryKey.GetValue("registryValue"); - 4). Instantiate a string variable and assign it the value of the binary values:
String sampleConvertedBytes = New String(""); - 5). Iterate through the array of binary registry values and assign each to the string within a foreach loop, separating each value with a space:
foreach(byte x in sampleBytesFromRegistery)
{
sampleConvertedBytes += x.ToString() + " ";
} - 6). Return the converted string to calling code and utilize as necessary:
return sampleConvertedBytes;
previous post