得到软件环境的信息

C#:记得引用单元集using System.Collections;

private void button1_Click(object sender, EventArgs e)
        {
            listView1.View = View.Details;
            listView1.GridLines = true;
            listView1.Columns.Add("环境变量", 150, HorizontalAlignment.Left);
            listView1.Columns.Add("变量值", 150, HorizontalAlignment.Left);
            ListViewItem myitem;
            foreach(DictionaryEntry DEntry in Environment.GetEnvironmentVariables())
            {
                myitem = new ListViewItem(DEntry.Key.ToString(), 0);
                myitem.SubItems.Add(DEntry.Value.ToString());
                listView1.Items.Add(myitem);
            }
                        
        }

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);
var
 p: PWideChar;
begin

  p:=  GetEnvironmentStrings;
  while(p^<>#0) do
  begin
    Memo1.Lines.Add(StrPas(p));
    inc(p,lstrlen(p)+1);
  end;

end;

 

posted on 2012-12-18 16:42  天上星  阅读(178)  评论(0编辑  收藏  举报

导航