获取当前用户名 [英] Getting current user name

查看:77
本文介绍了获取当前用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取当前登录Windows的用户的登录名为

字符串?


谢谢,

Steve Enzer

How can I get the login name of the user currently logged into Windows as a
string?

Thanks,
Steve Enzer

推荐答案

嗨Steve,


System.Environment.UserName


-


致敬,

Carlos J. Quintero


MZ-Tools:Visual Studio的生产力插件

您可以更快地编码,设计和记录:
http://www.mztools.com

" Steve Enzer" <无**** @ nospam.com> escribióenel mensaje

news:e1 ************** @ TK2MSFTNGP10.phx.gbl ...
Hi Steve,

System.Environment.UserName

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Steve Enzer" <no****@nospam.com> escribió en el mensaje
news:e1**************@TK2MSFTNGP10.phx.gbl...
我怎样才能得到当前登录Windows的用户的登录名是否为字符串?

谢谢,
Steve Enzer
How can I get the login name of the user currently logged into Windows as
a string?

Thanks,
Steve Enzer



" Carlos J. Quintero [VB MVP]" < CA ***** @ NOSPAMsogecable.com>在留言新闻中写道:Op ************** @ TK2MSFTNGP10.phx.gbl ...
"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAMsogecable.com> wrote in message news:Op**************@TK2MSFTNGP10.phx.gbl...
嗨Steve,

系统。 Environment.UserName


多么简单。我一直在使用

System.Security.Principal.WindowsIdentity.GetCurre nt()。名称


-


Al Reid


-

致以最诚挚的问候,

Carlos J. Quintero
Hi Steve,

System.Environment.UserName
How simple. Ive been using
System.Security.Principal.WindowsIdentity.GetCurre nt().Name

--

Al Reid


--

Best regards,

Carlos J. Quintero



您好,


进口System.Security

进口System.Security.Principal


AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)

Dim myID As WindowsIdentity = WindowsIdentity.GetCurrent()

Msgbox(" The Current User is:" ;& myID.Name)


问候,

Cerebrus。

Hi,

Imports System.Security
Imports System.Security.Principal

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)
Dim myID As WindowsIdentity = WindowsIdentity.GetCurrent()
Msgbox("The Current User is : " & myID.Name)

Regards,
Cerebrus.


这篇关于获取当前用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆