现在的位置: 首页 > 综合 > 正文

WPF 中获取系统信息

2012年09月20日 ⁄ 综合 ⁄ 共 861字 ⁄ 字号 评论关闭

首先添加 mscorlib assembly的命名空间引用

  xmlns:r="clr-namespace:System;assembly=mscorlib"

 XAML代码

<TextBlock>
<Label Content="Operating System Version : "></Label>
<Label Content="{x:Static r:Environment.OSVersion}"></Label>
<LineBreak></LineBreak>
<Label Content="Dot NET Version : "></Label>
<Label Content="{x:Static r:Environment.Version}"></Label>
<LineBreak></LineBreak>
<Label Content="Machine Name : "></Label>
<Label Content="{x:Static r:Environment.MachineName}"></Label>
<LineBreak></LineBreak>
<Label Content="User Name : "></Label>
<Label Content="{x:Static r:Environment.UserName}"></Label>

<LineBreak></LineBreak>
<Label Content="User Domain Name : "></Label>
<Label Content="{x:Static r:Environment.UserDomainName}"></Label>
<LineBreak></LineBreak>
<Label Content="System Directory : "></Label>
<Label Content="{x:Static r:Environment.SystemDirectory}"></Label>

</TextBlock>

 

 

 

抱歉!评论已关闭.