Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# get username

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Comment

c# get username

Environment.UserName
Comment

c# get username


string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

Comment

c# get logged on user name

foreach (System.Management.ManagementObject Process in Processes.Get())
{
    if (Process["ExecutablePath"] != null && 
        System.IO.Path.GetFileName(Process["ExecutablePath"].ToString()).ToLower() == "explorer.exe" )
    {
        string[] OwnerInfo = new string[2];
        Process.InvokeMethod("GetOwner", (object[])OwnerInfo);

        Console.WriteLine(string.Format("Windows Logged-in Interactive UserName={0}", OwnerInfo[0]));

        break;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity how to set gameobjkect enabled 
Csharp :: how to edit text mesh pro text 
Csharp :: ngrok for asp.net core 
Csharp :: unity how to get y value 
Csharp :: c# math to radiant 
Csharp :: vb.net wait 1 second 
Csharp :: camera follow 
Csharp :: Check object is in layermask unity 
Csharp :: how to change the color of an object in unity c# 
Csharp :: c# for each textbox lines 
Csharp :: how to reload current scene unity 
Csharp :: how to disable and enable rigidbody unity 
Csharp :: convert base64 string to string c# 
Csharp :: c# datetime dd/mm/yyy hh:mm:ss 
Csharp :: Animator.GotoState: State could not be found UnityEngine.Animator:Play (string) 
Csharp :: set player position unity 
Csharp :: writeline c# 
Csharp :: add two numbers in c# 
Csharp :: path desktop c# 
Csharp :: windows form rounded corners 
Csharp :: openfiledialog c# 
Csharp :: c# print out whole object 
Csharp :: how to make c# program run cmd commands 
Csharp :: How to read StreamReader text line by line 
Csharp :: c# get project directory 
Csharp :: photon how to destroy object 
Csharp :: set active text unity 
Csharp :: unity find closest point on line 
Csharp :: Exit string qoutes c# 
Csharp :: load prefab in script unity 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =