/// <summary>
 /// This method will insert a value into the VREG.
 /// </summary>
 /// <param name="hKey">A handle to an open registry key.</param>
 /// <param name="lpValueName">
 /// The name of the value to be set. If a value with this name is not already present in the key,
 /// the function adds it to the key.
 /// If lpValueName is NULL or an empty string, "", the function sets the type and data for
 /// the key's unnamed or default value.
 /// </param>
 /// <param name="reserved">This parameter is reserved and must be zero.</param>
 /// <param name="dwType">The type of data pointed to by the <paramref name="lpData"/> parameter.</param>
 /// <param name="lpData">The data to be stored.</param>
 /// <param name="cbData">The size of the information pointed to by the lpData parameter, in bytes.</param>
 /// <returns>A WinError code.</returns>
 public NativeResultCode SetValueEx(UIntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string lpValueName,
                                       uint reserved, ValueType dwType, IntPtr lpData, uint cbData)
 {
   uint handle;
   if (!TryParse(hKey, out handle))
     return NativeResultCode.InvalidHandle;
   using (EngineCore.Engine.GetEngineProcessingSpace())
   {
     var data = lpData.Read<byte[]>(cbData);
     var registryValue = new VirtualRegistryValue(lpValueName, data, dwType);
     var resultCode = _registry.SetValue(handle, registryValue);
     EngineCore.Log.Debug("SetValue(HKey={0} Name={1} Type={2}) => {3}",
                         handle, lpValueName, dwType, resultCode);
     return resultCode;
   }
 }