Setting hex value in registry

  • Thread starter Thread starter PeterB
  • Start date Start date
P

PeterB

Using OpenNETCF (or any other API with the ability to set registry values),
how would one go about and set the following key:

[HKEY_LOCAL_MACHINE\Time]
"TimeZoneInformation"=hex:c4,ff,ff,ff,57,00,2e,00,20,00,45,00,75,00,72,00,6f,00,70,00,65,00,20,00,53,\
00,74,00,61,00,6e,00,64,00,61,00,72,00,64,00,20,00,54,00,69,00,6d,00,65,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0a,00,00,00,05,\
00,03,00,00,00,00,00,00,00,00,00,00,00,57,00,2e,00,20,00,45,00,75,00,72,00,\
6f,00,70,00,65,00,20,00,44,00,61,00,79,00,6c,00,69,00,67,00,68,00,74,00,20,\
00,54,00,69,00,6d,00,65,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,03,00,00,00,05,00,02,00,00,00,00,00,00,00,c4,ff,ff,ff

Thanks,

Peter
 
To answer my own question:

I used this to perform the byte convertion:
http://www.codeproject.com/csharp/HexEncoding.asp

//Removed the commas and made a string of it.
const string strHexSweTZI =
"c4ffffff57002e0020004500750072006f007000650020005300740061006e0064006100720064002000540069006d00650000000000000000000000000000000000000000000a000000050003000000000000000000000057002e0020004500750072006f007000650020004400610079006c0069006700680074002000540069006d00650000000000000000000000000000000000000000000300000005000200000000000000c4ffffff";
int iDisc;
byte[] btData = HexEncoding.GetBytes(strHexSweTZI, out iDisc);

RegistryKey rKey;
rKey = Registry.LocalMachine.OpenSubKey("Time", true);
rKey.SetValue("TimeZoneInformation", btData);


But the most efficient way would be to excplicitly create the byte array
right off the data:
byte[] btData = new byte[] {196, 255, 255, 255, 87, 0, ... };

/ Peter
 
Back
Top