Пример #1
0
        /// <summary>
        /// Get the system uptime
        /// </summary>
        /// <returns>System uptime</returns>
        public async Task <Uptime> GetSystemUpTime()
        {
            var queryString = "SELECT LastBootUpTime FROM Win32_OperatingSystem";
            var wmiReader   = new WmiReader();
            var results     = await wmiReader.ExecuteScalar(queryString);

            return(new Uptime()
            {
                UpTime = Uptime.ParseUpTime(results["LastBootUpTime"].ToString())
            });
        }
Пример #2
0
        /// <summary>
        /// Provide the operating system information
        /// </summary>
        /// <returns>Operating system information </returns>
        public async Task <OSInfo> GetOSInfo()
        {
            var queryString = "SELECT caption, version, CSName FROM Win32_OperatingSystem";
            var wmiReader   = new WmiReader();
            var results     = await wmiReader.ExecuteScalar(queryString);

            return(new OSInfo()
            {
                MachineName = results["CSName"].ToString(),
                OSName = results["caption"].ToString(),
                Version = results["version"].ToString()
            });
        }