Nucleus handler tools โบ Docs โบ Context โบ EditRegKey
Context.EditRegKey
Open in the workbench (search, and try it in a handler)
Context.EditRegKey(
baseKey: string,
sKey: string,
subKey: string,
value: any,
regType: Nucleus.RegType
): void
Edit a registry key for current user, baseKey can either be "HKEY_LOCAL_MACHINE" or "HKEY_CURRENT_USER".
EditRegKey uses a custom registry data type to use, by using Nucleus.RegType.DWord for example. The last word can be of the same name of RegistryValueKind enum.
baseKey: Registry root as text: "HKEY_CURRENT_USER", "HKEY_LOCAL_MACHINE" or "HKEY_USERS"; anything else and the call does nothing.sKey: Key path under the root, e.g. "Software\\Company\\Game"; created if missing. Before the first edit Nucleus exports it to utils\backup\<last part>.reg.subKey: Name of the value to set inside that key.value: The data to write; null does nothing. For RegType.Binary the value's text is stored as UTF-8 bytes.regType: Value type: Nucleus.RegType.String, DWord, QWord, Binary, ExpandString or MultiString (the names of .NET's RegistryValueKind).
Category: Registry
In practice
Before it first changes a key, Nucleus exports it to utils\backup\<key>.reg, which it imports again afterwards (Context.EditRegKeyNoBackup skips that); a missing key is created. Only HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE and HKEY_USERS work; anything else, or a null value, is ignored without a word. Handlers use it in Game.Play for games that keep their resolution or window mode in the registry, which is mostly Unity games: they keep their screen settings in HKEY_CURRENT_USER\SOFTWARE\<company>\<game>, and handlers set Screenmanager Resolution Width and Height there (the names end in a hash, _h182942802).
By engine: more common in Unity games, rarer in Source and Unreal Engine games.
Example
Context.EditRegKey(
"HKEY_CURRENT_USER",
"SOFTWARE\\Developer\\Game",
"Screenmanager Resolution Width",
Context.Width,
Nucleus.RegType.DWord
);