GetEnvironmentVariable function kernel32

Win32Result<int> GetEnvironmentVariable(
  1. PCWSTR? lpName,
  2. PWSTR? lpBuffer,
  3. int nSize
)

Retrieves the contents of the specified variable from the environment block of the calling process.

To learn more, see learn.microsoft.com/windows/win32/api/processenv/nf-processenv-getenvironmentvariablew.

Implementation

Win32Result<int> GetEnvironmentVariable(
  PCWSTR? lpName,
  PWSTR? lpBuffer,
  int nSize,
) {
  final result_ = GetEnvironmentVariableW_Wrapper(
    lpName ?? nullptr,
    lpBuffer ?? nullptr,
    nSize,
  );
  return .new(value: result_.value.u32, error: result_.error);
}