mirror of
https://github.com/quasar/Quasar.git
synced 2026-10-25 01:40:20 +08:00
- Improved Client Installation, Update and Uninstallation - Improved Registry Access - Split SystemCore class
75 lines
2.6 KiB
C#
75 lines
2.6 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Management;
|
|
|
|
namespace xClient.Core.Helper
|
|
{
|
|
public static class SystemHelper
|
|
{
|
|
public static string GetUptime()
|
|
{
|
|
long ticks = Stopwatch.GetTimestamp();
|
|
double uptime = ((double)ticks) / Stopwatch.Frequency;
|
|
var uptimeSpan = TimeSpan.FromSeconds(uptime);
|
|
return string.Format("{0}d : {1}h : {2}m : {3}s", uptimeSpan.Days, uptimeSpan.Hours, uptimeSpan.Minutes, uptimeSpan.Seconds);
|
|
}
|
|
|
|
public static string GetPcName()
|
|
{
|
|
return Environment.MachineName;
|
|
}
|
|
|
|
public static string GetAntivirus()
|
|
{
|
|
try
|
|
{
|
|
string antivirusName = string.Empty;
|
|
// starting with Windows Vista we must use the root\SecurityCenter2 namespace
|
|
string scope = (PlatformHelper.VistaOrHigher) ? "root\\SecurityCenter2" : "root\\SecurityCenter";
|
|
string query = "SELECT * FROM AntivirusProduct";
|
|
|
|
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
|
|
{
|
|
foreach (ManagementObject mObject in searcher.Get())
|
|
{
|
|
antivirusName = mObject["displayName"].ToString() + "; ";
|
|
}
|
|
}
|
|
antivirusName = FormatHelper.RemoveEnd(antivirusName);
|
|
|
|
return (!string.IsNullOrEmpty(antivirusName)) ? antivirusName : "N/A";
|
|
}
|
|
catch
|
|
{
|
|
return "Unknown";
|
|
}
|
|
}
|
|
|
|
public static string GetFirewall()
|
|
{
|
|
try
|
|
{
|
|
string firewallName = string.Empty;
|
|
// starting with Windows Vista we must use the root\SecurityCenter2 namespace
|
|
string scope = (PlatformHelper.VistaOrHigher) ? "root\\SecurityCenter2" : "root\\SecurityCenter";
|
|
string query = "SELECT * FROM FirewallProduct";
|
|
|
|
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
|
|
{
|
|
foreach (ManagementObject mObject in searcher.Get())
|
|
{
|
|
firewallName = mObject["displayName"].ToString() + "; ";
|
|
}
|
|
}
|
|
firewallName = FormatHelper.RemoveEnd(firewallName);
|
|
|
|
return (!string.IsNullOrEmpty(firewallName)) ? firewallName : "N/A";
|
|
}
|
|
catch
|
|
{
|
|
return "Unknown";
|
|
}
|
|
}
|
|
}
|
|
}
|