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 :: mouse position to canvas transform 
Csharp :: c# user name session 
Csharp :: c# date to julian YYJJJ date 
Csharp :: C# Character and String Literals 
Csharp :: keep sprites at fixed transform according to screen resolution unity 
Csharp :: unity matchinfo 
Csharp :: JAJAAJAJAJ 
Csharp :: matric multiplication 
Csharp :: c# odd or even 
Csharp :: in model add to give drop down message 
Csharp :: remove last character from stringbuilder c# 
Csharp :: c# switch two values 
Csharp :: c# show hidden window wpf 
Csharp :: ddsfsd 
Csharp :: c# class reference 
Csharp :: qcombobox delegate text filter 
Csharp :: bunifu form fade transition c# 
Csharp :: Transparent UserControl 
Csharp :: Xamarin Forms Update Button Text Code 
Csharp :: bitter foods examplews 
Csharp :: c# is not 
Csharp :: c# inline 
Csharp :: entity framework where date between 
Csharp :: how to textbox anywhere on chart in c# 
Csharp :: unity how to get data of play session time in a text file? 
Csharp :: c# listview 
Csharp :: c# blazor in .net framework 
Csharp :: deserialize list of objects c# 
Csharp :: Selecting item from listview in C# 
Csharp :: 0.8 dikali 0.8 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =