If you don’t mind compile some C code, here’s how Jason Hickey’s libmojave does it, and it is compatible with Win32: