• 大小: 71KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: C#
  • 标签: WMI  CPU  硬盘  网速  

资源简介

WMI 获取计算机信息(cpu 硬盘 网卡 网速)C# 源码

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Net;
using System.Net.NetworkInformation;

using System.Collections;
using System.Management;

namespace WINInfo
{
    public partial class Form1 : Form
    { 
        public ManagementScope RemoteScope;//远程连接
        public ManagementScope LocalScope; //本机连接
        public bool bLocalFlg; //本机初始化标识
        public bool bRemoteFlg;

        public Form1()
        {
            InitializeComponent();
            bLocalFlg = true;
            bRemoteFlg = true;
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }

        private void GetWinInfo_Click(object sender EventArgs e)
        {
            try
            {
                if (bRemoteFlg)
                {
                    //判断远程是否能连接

                    Ping pingSender = new Ping(); //Ping既然是类,为何不变色?
                    PingReply reply = pingSender.Send(this.TextIP.Text);
                    if (reply.Status == IPStatus.Success)
                    {
                        string message = string.Format(“地址:{0}连接测试成功!“ this.TextIP.Text);
                        MessageBox.Show(message);
                    }
                    else
                    {
                        string message = string.Format(“地址:{0}连接测试失败!“ this.TextIP.Text);
                        MessageBox.Show(message);

                        ListViewItem Item1 = new ListViewItem(new string[] { this.TextIP.Text ““ ““ ““ ““ “““连接失败“ } -1);
                        this.ListRec.Items.Add(Item1);

                        return;
                    }

                    //连接
                    ConnectionOptions connection = new ConnectionOptions();
                    connection.Username = this.TextUserName.Text;
                    connection.Password = this.TextPassword.Text;
                    connection.Authority = “ntlmdomain:“;

                    string strPath = “\\\\“+this.TextIP.Text + “\\root\\CIMV2“;

                    RemoteScope = new ManagementScope(
                        strPath  connection);
                    RemoteScope.Connect();

                    bRemoteFlg = false;
                }
                

                // 获取物理内存
                string strMemory = ““;

                objectQuery query = new objectQuery(“SELECT * FROM Win32_OperatingSystem“);

                ManagementobjectSearcher searcher =
                    new ManagementobjectSearcher(RemoteScope query);

                foreach (Managementobject queryObj in searcher.Get())
                {
                    double nTotalMer = Convert.ToDouble(queryObj[“TotalVisibleMemorySize“]);
                    double nFreeMer = Convert.ToDouble(queryObj[“FreePhysicalMemory“]);

      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      40960  2012-09-17 09:59  获取计算机性能数据\WINInfo\bin\Debug\Interop.MMC20.dll

     文件      16896  2012-09-20 10:41  获取计算机性能数据\WINInfo\bin\Debug\WINInfo.exe

     文件      32256  2012-09-20 10:41  获取计算机性能数据\WINInfo\bin\Debug\WINInfo.pdb

     文件      14328  2012-09-20 10:42  获取计算机性能数据\WINInfo\bin\Debug\WINInfo.vshost.exe

     文件        490  2007-07-21 02:33  获取计算机性能数据\WINInfo\bin\Debug\WINInfo.vshost.exe.manifest

     文件      14012  2012-09-20 10:41  获取计算机性能数据\WINInfo\Form1.cs

     文件      10434  2012-09-20 10:41  获取计算机性能数据\WINInfo\Form1.Designer.cs

     文件       5814  2012-09-20 10:41  获取计算机性能数据\WINInfo\Form1.resx

     文件      40960  2012-09-17 09:59  获取计算机性能数据\WINInfo\obj\Debug\Interop.MMC20.dll

     文件        730  2012-09-20 10:42  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.csproj.FileListAbsolute.txt

     文件        847  2012-09-20 10:41  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.csproj.GenerateResource.Cache

     文件        544  2012-09-17 09:59  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.csproj.ResolveComReference.cache

     文件      16896  2012-09-20 10:41  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.exe

     文件        180  2012-09-20 10:41  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.Form1.resources

     文件      32256  2012-09-20 10:41  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.pdb

     文件        180  2012-09-17 10:01  获取计算机性能数据\WINInfo\obj\Debug\WINInfo.Properties.Resources.resources

     文件        488  2012-09-17 09:15  获取计算机性能数据\WINInfo\Program.cs

     文件       1356  2012-09-17 09:15  获取计算机性能数据\WINInfo\Properties\AssemblyInfo.cs

     文件       2864  2012-09-17 09:15  获取计算机性能数据\WINInfo\Properties\Resources.Designer.cs

     文件       5612  2012-09-17 09:15  获取计算机性能数据\WINInfo\Properties\Resources.resx

     文件       1092  2012-09-17 09:15  获取计算机性能数据\WINInfo\Properties\Settings.Designer.cs

     文件        249  2012-09-17 09:15  获取计算机性能数据\WINInfo\Properties\Settings.settings

     文件        378  2012-09-17 09:50  获取计算机性能数据\WINInfo\UserControl1.cs

     文件       1118  2012-09-17 09:50  获取计算机性能数据\WINInfo\UserControl1.Designer.cs

     文件       4209  2012-09-17 10:01  获取计算机性能数据\WINInfo\WINInfo.csproj

     文件        911  2012-09-17 09:15  获取计算机性能数据\WINInfo.sln

    ..A..H.     16896  2012-09-20 10:09  获取计算机性能数据\WINInfo.suo

     目录          0  2012-09-20 10:45  获取计算机性能数据\WINInfo\obj\Debug\Refactor

     目录          0  2012-09-20 10:45  获取计算机性能数据\WINInfo\obj\Debug\TempPE

     目录          0  2012-09-20 10:45  获取计算机性能数据\WINInfo\bin\Debug

............此处省略10个文件信息

评论

共有 条评论