[Solved] Registry (Hex or int) to ip Address? lazarus / 34-Windows ---------------------------------------------------------------------- TheLastCayen · 2021-11-15 16:31 I am using Lazarus 2.0.12 FPC 3.2.0 Windows 10 I need to read an IP Address from the registry. The IP has been written per a 3rd party software and it's part of that software configuration. As an example, the value from the registry is: 1E32A8C0 1E = 30 32 = 50 A8 = 168 C0 = 192 So the ip address is 192.168.50.30 (not sure why they saved it in this order, probably a pile) If I read the number as an integer, the value is 506636480. From there, I am totally lost. It seems easier to use the Hex value in order to extract my ip and I know I can "Registry.ReadInteger", then convert using IntToHex((X), );. fpc don't seem really friendly to work with Hex value. I am not sure how to isolate the number in pair of 2 so I can get the ip address per section. I am not sure how to work with the decimal version either. I don't see any hex variable I can work with and I am not too familiar with pointers.  Anyone can recommend a way to read this ip address or some documentation to  point me in the right direction? Thank you ---------------------------------------------------------------------- MarkMLl · 2021-11-15 16:43 So it looks as though it's stored as a little-endian (i.e. x86 native format) 32-bit word. Try https://www.freepascal.org/docs- html/current/rtl/system/ntobe.html etc. MarkMLl ---------------------------------------------------------------------- winni · 2021-11-15 17:09 Hi! IP addresses in the Windows registry are from the type REG_SZ whichs is a zero terminated string. So you should not look for integers/Dwords but for strings with 3 dots in it. Winni ---------------------------------------------------------------------- Bart · 2021-11-15 17:17 From your example it looks like you need to parse is as (pseudocode). Lo(LoWord(Value)) . Hi(LoWord(Value)) . Lo(HiWord(Value)) . Hi(HiWordValue)) This would give you (Value=1E32A8C0): 192.168.50.30 Bart ---------------------------------------------------------------------- wp · 2021-11-15 17:27 This is a simple converter: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function IPAddressFromInteger(x: LongInt): String;type  TIPAddress = packed record b1, b2, b3, b4: byte; end;begin  with TIPAddress(x) do    Result := Format('%d.%d.%d.%d', [b1, b2, b3, b4]);end; ---------------------------------------------------------------------- Remy Lebeau · 2021-11-15 18:01 Quote from: winni on November 15, 2021, 06:09:56 pmIP addresses in the Windows registry are from the type REG_SZ whichs is a zero terminated string. Clearly, the Registry value in question is not stored in REG_SZ format, but in REG_DWORD or REG_BINARY format, otherwise this wouldn't even be an issue. ---------------------------------------------------------------------- TheLastCayen · 2021-11-15 23:07 Thank you everyone for your quick answer. wp function fixed my puzzle