VSTO里取当前电脑所在域

private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
}

 

 

C#里只需要这么一句话,而VBA环境里试了好几个方法,包括VBA本身功能、API、SHELL、注册表等,却都是只能取到本地机器名,无法取到公司里的域名。

posted @ 2010-03-04 22:49  RobinLao  阅读(695)  评论(1编辑  收藏  举报