This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ticks = Stopwatch.GetTimestamp(); | |
| var uptime = ((double)ticks) / Stopwatch.Frequency; | |
| return TimeSpan.FromSeconds(uptime); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string GetLoggedInUserName() | |
| { | |
| try | |
| { | |
| using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT UserName FROM Win32_ComputerSystem")) | |
| { | |
| foreach (ManagementObject queryObj in searcher.Get()) | |
| { | |
| string userName = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string GetComputerManufacturer() | |
| { | |
| ManagementClass mc = new ManagementClass("Win32_ComputerSystem"); | |
| ManagementObjectCollection moc = mc.GetInstances(); | |
| if (moc.Count != 0) | |
| { | |
| foreach (ManagementObject mo in mc.GetInstances()) | |
| { | |
| return mo["Manufacturer"].ToString(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string GetHostName() | |
| { | |
| try | |
| { | |
| return Dns.GetHostEntry("").HostName; | |
| } | |
| catch {} | |
| return Environment.MachineName; |