winapi icon indicating copy to clipboard operation
winapi copied to clipboard

setenv invalid description

Open moteus opened this issue 13 years ago • 3 comments

For setenv you write that this function set variable only to childe process. This is not true. To test

local winapi = require"winapi"
os.execute("git help") -- this call fail
local path = os.getenv("PATH") .. ';c:\\git\\bin'
winapi.setenv("path", path)
os.execute("git help") -- but this pass

getenv create snpshot Environments while load dll and then return same variable. In my env library i write tests to check all possible variants and os.getenv never get new value, but GetEnvironmentVariable/getnev(from my dll)/getenv_s/environ return new value. May be on *nix this is not true.

moteus avatar Jul 09 '12 13:07 moteus

OK, that makes sense - os.getenv() is a portable version, but does not fully behave as it should (not an uncommon problem with Windows). So maybe winapi.getenv? Does this matter enough? I agree that the description should be updated.

stevedonovan avatar Jul 09 '12 13:07 stevedonovan

I implement 5 functions for env get/set/expand/environ/update. Update broadcast WM_SETTINGCHANGE like MSDN says, but i can not understand how it work. You can use my implementation of env functions.

moteus avatar Jul 09 '12 15:07 moteus

So maybe winapi.getenv? Does this matter enough?

I use my lib loader that automatically append ENV.PATH before load cmodule to find depedency .dll

local path = path_jopin(LIB_ROOT, 'path')
if dir_exists(path) then
  ENV.PATH = path .. ';' .. ENV.PATH
end

moteus avatar Jul 11 '12 10:07 moteus