Result<Environment> Environment::CreateForCurrentProcess(Trace& trace) { trace < L"Environment::CreateForCurrentProcess"; auto environment = GetEnvironmentStringsW(); Environment newEnvironment; try { newEnvironment.CreateVariableMap(environment, trace); } catch(...) { } FreeEnvironmentStringsW(environment); return newEnvironment; }
Result<Environment> Environment::CreateForUser(const Handle& token, bool inherit, Trace& trace) { trace < L"Environment::CreateForUser"; Environment newEnvironment; LPVOID environment; if (!CreateEnvironmentBlock(&environment, token, inherit)) { return Result<Environment>(ErrorUtilities::GetErrorCode(), ErrorUtilities::GetLastErrorMessage(L"CreateEnvironmentBlock")); } try { newEnvironment.CreateVariableMap(environment, trace); } catch (...) { } DestroyEnvironmentBlock(environment); return newEnvironment; }
Result<Environment> Environment::CreateForUser(const Handle& token, bool inherit, Trace& trace) { trace < L"Environment::CreateForUser"; Environment newEnvironment; LPVOID environment; if (!CreateEnvironmentBlock(&environment, token, inherit)) { return Error(L"CreateEnvironmentBlock"); } try { newEnvironment.CreateVariableMap(environment, trace); } catch (...) { } DestroyEnvironmentBlock(environment); return newEnvironment; }