More corelib cleanup (dotnet/coreclr#26993)
[mono-project.git] / netcore / System.Private.CoreLib / shared / Interop / Windows / Kernel32 / Interop.GetEnvironmentVariable.cs
blob43463e52304cb023e48c76df989d05ca449df203
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System;
6 using System.Runtime.InteropServices;
8 internal static partial class Interop
10 internal static partial class Kernel32
12 internal static unsafe int GetEnvironmentVariable(string lpName, Span<char> buffer)
14 fixed (char* bufferPtr = &MemoryMarshal.GetReference(buffer))
16 return GetEnvironmentVariable(lpName, bufferPtr, buffer.Length);
20 [DllImport(Libraries.Kernel32, EntryPoint = "GetEnvironmentVariableW", SetLastError = true, CharSet = CharSet.Unicode)]
21 private static extern unsafe int GetEnvironmentVariable(string lpName, char* lpBuffer, int nSize);