diff --git a/PInvoke/Kernel32/ProcessEnv.cs b/PInvoke/Kernel32/ProcessEnv.cs index 759282ef..da7e2789 100644 --- a/PInvoke/Kernel32/ProcessEnv.cs +++ b/PInvoke/Kernel32/ProcessEnv.cs @@ -270,13 +270,17 @@ namespace Vanara.PInvoke public static extern bool SetCurrentDirectory(string lpPathName); /// Sets the environment strings. - /// The new environment strings as a list of strings. + /// + /// The new environment strings. List of unicode null terminated strings with a double null termination at the end. + /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// [PInvokeData("ProcessEnv.h", MSDNShortId = "")] - public static bool SetEnvironmentStrings(IEnumerable NewEnvironment) => SetEnvironmentStringsW(NewEnvironment.ToArray()); + [DllImport(Lib.Kernel32, SetLastError = true, EntryPoint = "SetEnvironmentStringsW", CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetEnvironmentStrings([In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NullTermStringArrayMarshaler), MarshalCookie = "Unicode")] string[] NewEnvironment); /// Sets the contents of the specified environment variable for the current process. /// @@ -354,19 +358,6 @@ namespace Vanara.PInvoke [DllImport(Lib.Kernel32, SetLastError = false, EntryPoint = "GetCommandLine", CharSet = CharSet.Auto)] private static extern IntPtr GetCommandLineInternal(); - /// Sets the environment strings. - /// - /// The new environment strings. List of unicode null terminated strings with a double null termination at the end. - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [PInvokeData("ProcessEnv.h", MSDNShortId = "")] - [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool SetEnvironmentStringsW([In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NullTermStringArrayMarshaler), MarshalCookie = "Unicode")] string[] NewEnvironment); - /// Represents a block of environment strings obtained by and freed by . /// ///