//+private package os2 //import "core:runtime" //import "core:mem" import win32 "core:sys/windows" _get_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { if key == "" { return } wkey := win32.utf8_to_wstring(key) // https://docs.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentvariablew buf_len := win32.GetEnvironmentVariableW(wkey, nil, 0) if buf_len == 0 { return } buf := make([dynamic]u16, buf_len, context.temp_allocator) n := win32.GetEnvironmentVariableW(wkey, raw_data(buf), buf_len) if n == 0 { if win32.GetLastError() == win32.ERROR_ENVVAR_NOT_FOUND { return "", false } value = "" found = true return } value = win32.utf16_to_utf8(buf[:n], allocator) found = true return } _set_env :: proc(key, value: string) -> bool { k := win32.utf8_to_wstring(key) v := win32.utf8_to_wstring(value) // https://docs.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-setenvironmentvariablew return bool(win32.SetEnvironmentVariableW(k, v)) } _unset_env :: proc(key: string) -> bool { k := win32.utf8_to_wstring(key) // https://docs.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-setenvironmentvariablew return bool(win32.SetEnvironmentVariableW(k, nil)) } _clear_env :: proc() { envs := environ(context.temp_allocator) for env in envs { #no_bounds_check for j in 1..