I've been tinkering with this for the past couple of hours and don't think it's possible.
OpenKey = Win32API.new('advapi32', 'RegOpenKeyEx', 'lpllp', 'l')
SetKey = Win32API.new('advapi32', 'RegSetValueEx', 'lpllpl', 'l')
CloseKey = Win32API.new('advapi32', 'RegCloseKey', 'l', 'l')
handle = [0].pack('L')
key = [0x80000001, # HKEY_CURRENT_USER , ref: https://www.rubydoc.info/stdlib/dl/2.0.0/Win32/Registry/Constants
'Software\\Enterbrain\\RGSS',
0,
2, #KEY_SET_VALUE
handle]
p OpenKey.call(*key) # successful = 0
hkey = handle.unpack('L').first
val = [0].pack('L')
reg = [hkey,
'PlaySound',#'SmoothMode',
0, # reserved, keep it 0
0x10, #REG_DWORD
val, # value to be set
4] # size of value, in bytes
p SetKey.call(*reg) # successful = 0
p CloseKey.call(hkey)
I had regedit open while running the game and can observe that the registry key did change. But when I press F1 to access the window, the change is not reflected. And after closing the game, the registry key reverts back. If I were to call this on a different key (say RGSS3), then the change is permanent. Opening a RMVXA Game.exe and pressing F1 reflected the updated value.
So my guess is that Game.exe reads the registry keys and values, uses them to initialize the values in the F1 window, then runs the game. When the EXE closes, it checks the values in the F1 window and applies them directly to the registry keys/values. So any registry key modifications done in-game are ultimately ignored.