Share via


How to put an IP address into a registry DWORD value

[[Edited 11th, 13th, 15th January, 2010]]

To specify an IP address in a registry value, there are usually two ways:

  • Type the dotted notation IP address directly (STRING values)
  • Convert the IP address to hex (DWORD values)

The dotted notation is just a convention to make life easier for humans and can only be used in String values. Here the IPv4 address is broken down into four separate bytes; the contents of each byte are expressed as a decimal value and the four decimal values are written down separated by periods (most significant byte first).

A DWORD, though, expects a 32-bit integer. To demonstrate how to derive an integer from a human-friendly-format address:
 
192 = 0xC0 (this is the most significant byte)
 16 = 0x10
1 = 0x01
20 = 0x14 (this is the least significant byte)
 
This would become the integer value 0xC0100114 that you then enter into the registry. 

Note - You can also write a little app to call the inet_addr() function to convert a string in dotted notation into a long word.