1 Star 0 Fork 1.2K

gisinaction/project_8049763

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SystemInforUtil.cs 2.86 KB
一键复制 编辑 原始数据 按行查看 历史
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
namespace SiMay.RemoteService.Loader
{
public class SystemInforUtil
{
public static string LocalIPV4
{
get
{
try
{
string HostName = Dns.GetHostName();
IPHostEntry IpEntry = Dns.GetHostEntry(HostName);
for (int i = 0; i < IpEntry.AddressList.Length; i++)
{
if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
return IpEntry.AddressList[i].ToString();
}
return string.Empty;
}
catch
{
return string.Empty;
}
}
}
public static string LocalCpuInfo
{
get
{
try
{
RegistryKey reg = Registry.LocalMachine;
reg = reg.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
return reg.GetValue("ProcessorNameString").ToString();
}
catch
{
return string.Empty;
}
}
}
public static string OSFullName
{
get
{
string fullName = "Unknown OS";
try
{
using (var searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem"))
{
foreach (ManagementObject os in searcher.Get())
{
fullName = os["Caption"].ToString();
break;
}
}
fullName = Regex.Replace(fullName, "^.*(?=Windows)", "").TrimEnd().TrimStart(); // Remove everything before first match "Windows" and trim end & start
var is64Bit = Environment.Is64BitOperatingSystem;
return $"{fullName} {(is64Bit ? 64 : 32)} Bit";
}
catch
{
return fullName;
}
}
}
public static long LocalMemorySize
{
get
{
try
{
Microsoft.VisualBasic.Devices.Computer My = new Microsoft.VisualBasic.Devices.Computer();
return (long)My.Info.TotalPhysicalMemory;
}
catch
{
return 0;
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/springjava/SiMayRemoteMonitorOS.git
git@gitee.com:springjava/SiMayRemoteMonitorOS.git
springjava
SiMayRemoteMonitorOS
project_8049763
master

搜索帮助