'Convert REG_BINARY 128-bit to a datetime

I'm trying to work out in C# how to convert a REG_BINARY 128-bit value to date and time. I know I can use Bitconverter for 64-bit values but that doesn't work for 128-bit.

The registry value is E5070A000500080012000D0018002703. I can use DCode with the Decode Format: Windows: 128 bit SYSTEM structure to get the date and time but want to know how to do this is C#. Can anyone help me please?

Dcode example



Solution 1:[1]

private static DateTime GetDateFrom128Byte(byte[] binary)
{
    if (binary == null || binary.Length != 16)
    {
        throw new ArgumentException();
    }

    return new DateTime(binary[0] + binary[1] * 256, binary[2], binary[6], binary[8], binary[10], 0);
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Soner Gönül