Visual Studio 2008扩展包Toolwindow需要显示用户名

发布于 2024-10-04 03:57:36 字数 166 浏览 0 评论 0原文

我有一个概念验证项目,作为其中的一部分,我需要确定在工具窗口上显示用户名(登录到 PC 的人)的最佳方式。 这个想法是从客户端而不是服务器或服务获取此信息。包首先是VS 2008,然后我需要在VS 2010中进行。我使用 WPF 作为首选 UI。我已经学习 VSX 的详细信息大约一周了,感谢所有指导。 谢谢,丹尼

I have a proof of concept project and as part of it I need to identify the best way to display the User Name(the person logged on the PC) on the ToolWindow.
The idea is to get this from the client and not the server or service. The package is to be VS 2008 first, then I need to do it in VS 2010 next. I am using WPF as the preferred UI. I am about a week into learning the ins and outs of VSX and appreciate all guidance.
Thanks, Danny

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救星 2024-10-11 03:57:36

好的,我得到答案了。
很简单,

System.Security.Principal.WindowsIdentity currentUser = System.Security.Principal.WindowsIdentity.GetCurrent();

字符串登录名 = 当前用户.Name;
tb1.Text = 登录名;

Ok, I got the answer.
Very simple,

System.Security.Principal.WindowsIdentity currentUser = System.Security.Principal.WindowsIdentity.GetCurrent();

string loginName = currentUser.Name;
tb1.Text = loginName;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文