确实没有迫切的理由让我问比其他好奇这个问题 - 使用C#,有没有办法从内部我的进程正在运行作为用户代码,以确定?为了说明使用代码:
static void Main(string[] args)
{
string userID;
//what goes here to fill in this userID variable?
Console.out.WriteLine(string.Format("This process is running as {0}.", userID));
}
Run Code Online (Sandbox Code Playgroud)
Mik*_*las 50
string userID = WindowsIdentity.GetCurrent().Name
Run Code Online (Sandbox Code Playgroud)
来自MSDN:WindowsIdentity.GetCurrent()和WindowsIdentity.Name