Exemplo n.º 1
0
 unsafe static void FillListBox(WindowHandle hwndList)
 {
     foreach (var name in ProcessMethods.GetEnvironmentVariables().Keys)
     {
         if (name[0] != '=') // Skip variable names beginning with '='
         {
             fixed(char *buffer = name)
             hwndList.SendMessage(ListBoxMessage.AddString, 0, buffer);
         }
     }
 }
Exemplo n.º 2
0
        public void ListEnvironmentVariables_Basic(string prefix)
        {
            string name = prefix + System.IO.Path.GetRandomFileName();

            ProcessMethods.SetEnvironmentVariable(name, "test");
            ProcessMethods.GetEnvironmentVariable(name).Should().Be("test");
            var variables = ProcessMethods.GetEnvironmentVariables();

            variables.Should().ContainKey(name);
            variables[name].Should().Be("test");
            ProcessMethods.SetEnvironmentVariable(name, null);
            ProcessMethods.GetEnvironmentVariable(name).Should().BeNull();
            variables = ProcessMethods.GetEnvironmentVariables();
            variables.Should().NotContainKey(name);
        }