标签:type control 获取本地ip地址 ports console except software 调用 lis
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 8 using System.Net; 9 using System.Management; //在项目-》添加引用....里面引用System.Management 10 using System.Runtime.InteropServices; 11 12 13 namespace FileSplit 14 { 15 //此类用于获取当前主机的相关信息 16 public class MachineInfo 17 { 18 //用法示例 19 private string example() 20 { 21 string Info = ""; 22 MachineInfo info = MachineInfo.I(); //获取主机的对象信息 23 24 25 Info = "\r\n主机名:" + Dns.GetHostName(); //获取主机名称 26 Info += "\r\n系统类型:" + info.GetSystemType(); 27 Info += "\r\n物理内存:" + info.GetPhysicalMemory(); 28 29 30 Info += "\r\n\r\n本地IP:"; 31 string[] LocalIp = info.GetLocalIpAddress(); 32 foreach (string ip in LocalIp) Info += "\r\n" + ip; 33 34 35 Info += "\r\n\r\n外网IP:"; 36 string[] ExternalIp = info.GetExtenalIpAddress(); 37 foreach (string ip in ExternalIp) Info += "\r\n" + ip; 38 39 40 Info += "\r\n\r\nMAC:"; 41 Info += "\r\n" + info.GetNetCardMACAddress(); 42 //Info += "\r\n" + info.GetMacAddress(LocalIp[0]); 43 44 45 Info += "\r\n"; 46 Info += "\r\nCPU序列号:" + info.GetCPUSerialNumber(); 47 //Info += "\r\nCPU编号:" + info.GetCPUID(); 48 //Info += "\r\nCPU版本信息:" + info.GetCPUVersion(); 49 //Info += "\r\nCPU名称信息:" + info.GetCPUName(); 50 //Info += "\r\nCPU制造厂商:" + info.GetCPUManufacturer(); 51 //Info += "\r\n主板制造厂商:" + info.GetBoardManufacturer(); 52 53 54 //Info += "\r\n主板序列号:" + info.GetBIOSSerialNumber(); 55 //Info += "\r\n硬盘序列号:" + info.GetHardDiskSerialNumber(); 56 //Info += "\r\n显卡PNPDeviceID:\r\n" + info.GetVideoPNPID(); 57 //Info += "\r\n声卡PNPDeviceID:\r\n" + info.GetSoundPNPID(); 58 59 60 return Info; 61 } 62 63 64 65 66 static MachineInfo Instance; 67 68 69 /// <summary> 70 /// 获取当前类对象的一个实例 71 /// </summary> 72 public static MachineInfo I() 73 { 74 if (Instance == null) Instance = new MachineInfo(); 75 return Instance; 76 } 77 78 /// <summary> 79 /// 获取本地ip地址,多个ip 80 /// </summary> 81 public String[] GetLocalIpAddress() 82 { 83 string hostName = Dns.GetHostName(); //获取主机名称 84 IPAddress[] addresses = Dns.GetHostAddresses(hostName); //解析主机IP地址 85 86 87 string[] IP = new string[addresses.Length]; //转换为字符串形式 88 for (int i = 0; i < addresses.Length; i++) IP[i] = addresses[i].ToString(); 89 90 91 return IP; 92 } 93 94 95 96 97 //从网站"http://1111.ip138.com/ic.asp",获取本机外网ip地址信息串 98 //"<html>\r\n<head>\r\n<meta http-equiv=\"content-type\" content=\"text/html; charset=gb2312\">\r\n<title> 99 //您的IP地址 </title>\r\n</head>\r\n<body style=\"margin:0px\"><center>您的IP是:[218.104.71.178] 来自:安徽省合肥市 联通</center></body></html>" 100 101 102 /// <summary> 103 /// 获取外网ip地址 104 /// </summary> 105 public string[] GetExtenalIpAddress() 106 { 107 string[] IP = new string[] { "未获取到外网ip", "" }; 108 109 110 string address = "http://1111.ip138.com/ic.asp"; 111 string str = GetWebStr(address); 112 113 114 try 115 { 116 //提取外网ip数据 [218.104.71.178] 117 int i1 = str.IndexOf("[") + 1, i2 = str.IndexOf("]"); 118 IP[0] = str.Substring(i1, i2 - i1); 119 120 121 //提取网址说明信息 "来自:安徽省合肥市 联通" 122 i1 = i2 + 2; i2 = str.IndexOf("<", i1); 123 IP[1] = str.Substring(i1, i2 - i1); 124 } 125 catch (Exception) { } 126 127 128 return IP; 129 } 130 131 132 /// <summary> 133 /// 获取网址address的返回的文本串数据 134 /// </summary> 135 public string GetWebStr(string address) 136 { 137 string str = ""; 138 try 139 { 140 //从网址中获取本机ip数据 141 System.Net.WebClient client = new System.Net.WebClient(); 142 client.Encoding = System.Text.Encoding.Default; 143 str = client.DownloadString(address); 144 client.Dispose(); 145 } 146 catch (Exception) { } 147 148 149 return str; 150 } 151 152 153 /// <summary> 154 /// 获取本机的MAC; //在项目-》添加引用....里面引用System.Management 155 /// </summary> 156 public string GetLocalMac() 157 { 158 string mac = null; 159 ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration"); 160 ManagementObjectCollection queryCollection = query.Get(); 161 foreach (ManagementObject mo in queryCollection) 162 { 163 if (mo["IPEnabled"].ToString() == "True") 164 mac = mo["MacAddress"].ToString(); 165 } 166 return (mac); 167 } 168 169 170 //只能获取同网段的远程主机MAC地址. 因为在标准网络协议下,ARP包是不能跨网段传输的,故想通过ARP协议是无法查询跨网段设备MAC地址的。 171 [DllImport("Iphlpapi.dll")] 172 private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length); 173 [DllImport("Ws2_32.dll")] 174 private static extern Int32 inet_addr(string ip); 175 /// <summary> 176 /// 获取ip对应的MAC地址 177 /// </summary> 178 public string GetMacAddress(string ip) 179 { 180 Int32 ldest = inet_addr(ip); //目的ip 181 Int32 lhost = inet_addr("127.0.0.1"); //本地ip 182 183 184 try 185 { 186 Int64 macinfo = new Int64(); 187 Int32 len = 6; 188 int res = SendARP(ldest, 0, ref macinfo, ref len); //使用系统API接口发送ARP请求,解析ip对应的Mac地址 189 return Convert.ToString(macinfo, 16); 190 } 191 catch (Exception err) 192 { 193 Console.WriteLine("Error:{0}", err.Message); 194 } 195 return "获取Mac地址失败"; 196 } 197 198 199 /// <summary> 200 /// 获取主板序列号 201 /// </summary> 202 /// <returns></returns> 203 public string GetBIOSSerialNumber() 204 { 205 try 206 { 207 ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_BIOS"); 208 string sBIOSSerialNumber = ""; 209 foreach (ManagementObject mo in searcher.Get()) 210 { 211 sBIOSSerialNumber = mo["SerialNumber"].ToString().Trim(); 212 } 213 return sBIOSSerialNumber; 214 } 215 catch 216 { 217 return ""; 218 } 219 } 220 221 222 /// <summary> 223 /// 获取CPU序列号 224 /// </summary> 225 /// <returns></returns> 226 public string GetCPUSerialNumber() 227 { 228 try 229 { 230 ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_Processor"); 231 string sCPUSerialNumber = ""; 232 foreach (ManagementObject mo in searcher.Get()) 233 { 234 sCPUSerialNumber = mo["ProcessorId"].ToString().Trim(); 235 } 236 return sCPUSerialNumber; 237 } 238 catch 239 { 240 return ""; 241 } 242 } 243 //获取硬盘序列号 244 public string GetHardDiskSerialNumber() 245 { 246 try 247 { 248 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); 249 string sHardDiskSerialNumber = ""; 250 foreach (ManagementObject mo in searcher.Get()) 251 { 252 sHardDiskSerialNumber = mo["SerialNumber"].ToString().Trim(); 253 break; 254 } 255 return sHardDiskSerialNumber; 256 } 257 catch 258 { 259 return ""; 260 } 261 } 262 263 264 //获取网卡地址 265 public string GetNetCardMACAddress() 266 { 267 try 268 { 269 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter WHERE ((MACAddress Is Not NULL) AND (Manufacturer <> ‘Microsoft‘))"); 270 string NetCardMACAddress = ""; 271 foreach (ManagementObject mo in searcher.Get()) 272 { 273 NetCardMACAddress = mo["MACAddress"].ToString().Trim(); 274 } 275 return NetCardMACAddress; 276 } 277 catch 278 { 279 return ""; 280 } 281 } 282 283 284 285 286 /// <summary> 287 /// 获得CPU编号 288 /// </summary> 289 public string GetCPUID() 290 { 291 string cpuid = ""; 292 ManagementClass mc = new ManagementClass("Win32_Processor"); 293 ManagementObjectCollection moc = mc.GetInstances(); 294 foreach (ManagementObject mo in moc) 295 { 296 cpuid = mo.Properties["ProcessorId"].Value.ToString(); 297 } 298 return cpuid; 299 } 300 301 302 /// <summary> 303 /// 获取硬盘序列号 304 /// </summary> 305 public string GetDiskSerialNumber() 306 { 307 //这种模式在插入一个U盘后可能会有不同的结果,如插入我的手机时 308 String HDid = ""; 309 ManagementClass mc = new ManagementClass("Win32_DiskDrive"); 310 ManagementObjectCollection moc = mc.GetInstances(); 311 foreach (ManagementObject mo in moc) 312 { 313 HDid = (string)mo.Properties["Model"].Value;//SerialNumber 314 break;//这名话解决有多个物理盘时产生的问题,只取第一个物理硬盘 315 } 316 return HDid; 317 318 319 /*ManagementClass mc = new ManagementClass("Win32_PhysicalMedia"); 320 ManagementObjectCollection moc = mc.GetInstances(); 321 string str = ""; 322 foreach (ManagementObject mo in moc) 323 { 324 str = mo.Properties["SerialNumber"].Value.ToString(); 325 break; 326 } 327 return str;*/ 328 } 329 330 331 /// <summary> 332 /// 获取网卡硬件地址 333 /// </summary> 334 public string GetMacAddress() 335 { 336 string mac = ""; 337 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); 338 ManagementObjectCollection moc = mc.GetInstances(); 339 foreach (ManagementObject mo in moc) 340 { 341 if ((bool)mo["IPEnabled"] == true) 342 { 343 mac = mo["MacAddress"].ToString(); 344 break; 345 } 346 } 347 return mac; 348 } 349 350 351 /// <summary> 352 /// 获取IP地址 353 /// </summary> 354 public string GetIPAddress() 355 { 356 string st = ""; 357 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); 358 ManagementObjectCollection moc = mc.GetInstances(); 359 foreach (ManagementObject mo in moc) 360 { 361 if ((bool)mo["IPEnabled"] == true) 362 { 363 //st=mo["IpAddress"].ToString(); 364 System.Array ar; 365 ar = (System.Array)(mo.Properties["IpAddress"].Value); 366 st = ar.GetValue(0).ToString(); 367 break; 368 } 369 } 370 return st; 371 } 372 373 374 /// <summary> 375 /// 操作系统的登录用户名 376 /// </summary> 377 public string GetUserName() 378 { 379 return Environment.UserName; 380 } 381 382 383 384 385 /// <summary> 386 /// 获取计算机名 387 /// </summary> 388 public string GetComputerName() 389 { 390 return Environment.MachineName; 391 } 392 393 394 /// <summary> 395 /// 操作系统类型 396 /// </summary> 397 public string GetSystemType() 398 { 399 string st = ""; 400 ManagementClass mc = new ManagementClass("Win32_ComputerSystem"); 401 ManagementObjectCollection moc = mc.GetInstances(); 402 foreach (ManagementObject mo in moc) 403 { 404 st = mo["SystemType"].ToString(); 405 } 406 return st; 407 } 408 409 410 /// <summary> 411 /// 物理内存 412 /// </summary> 413 public string GetPhysicalMemory() 414 { 415 string st = ""; 416 ManagementClass mc = new ManagementClass("Win32_ComputerSystem"); 417 ManagementObjectCollection moc = mc.GetInstances(); 418 foreach (ManagementObject mo in moc) 419 { 420 st = mo["TotalPhysicalMemory"].ToString(); 421 } 422 return st; 423 } 424 425 426 /// <summary> 427 /// 显卡PNPDeviceID 428 /// </summary> 429 public string GetVideoPNPID() 430 { 431 string st = ""; 432 ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_VideoController"); 433 foreach (ManagementObject mo in mos.Get()) 434 { 435 st = mo["PNPDeviceID"].ToString(); 436 } 437 return st; 438 } 439 440 441 /// <summary> 442 /// 声卡PNPDeviceID 443 /// </summary> 444 public string GetSoundPNPID() 445 { 446 string st = ""; 447 ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_SoundDevice"); 448 foreach (ManagementObject mo in mos.Get()) 449 { 450 st = mo["PNPDeviceID"].ToString(); 451 } 452 return st; 453 } 454 455 456 /// <summary> 457 /// CPU版本信息 458 /// </summary> 459 public string GetCPUVersion() 460 { 461 string st = ""; 462 ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_Processor"); 463 foreach (ManagementObject mo in mos.Get()) 464 { 465 st = mo["Version"].ToString(); 466 } 467 return st; 468 } 469 470 471 /// <summary> 472 /// CPU名称信息 473 /// </summary> 474 public string GetCPUName() 475 { 476 string st = ""; 477 ManagementObjectSearcher driveID = new ManagementObjectSearcher("Select * from Win32_Processor"); 478 foreach (ManagementObject mo in driveID.Get()) 479 { 480 st = mo["Name"].ToString(); 481 } 482 return st; 483 } 484 485 486 /// <summary> 487 /// CPU制造厂商 488 /// </summary> 489 public string GetCPUManufacturer() 490 { 491 string st = ""; 492 ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_Processor"); 493 foreach (ManagementObject mo in mos.Get()) 494 { 495 st = mo["Manufacturer"].ToString(); 496 } 497 return st; 498 } 499 500 501 /// <summary> 502 /// 主板制造厂商 503 /// </summary> 504 public string GetBoardManufacturer() 505 { 506 SelectQuery query = new SelectQuery("Select * from Win32_BaseBoard"); 507 ManagementObjectSearcher mos = new ManagementObjectSearcher(query); 508 ManagementObjectCollection.ManagementObjectEnumerator data = mos.Get().GetEnumerator(); 509 data.MoveNext(); 510 ManagementBaseObject board = data.Current; 511 return board.GetPropertyValue("Manufacturer").ToString(); 512 } 513 514 515 /// <summary> 516 /// 主板编号 517 /// </summary> 518 public string GetBoardID() 519 { 520 string st = ""; 521 ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_BaseBoard"); 522 foreach (ManagementObject mo in mos.Get()) 523 { 524 st = mo["SerialNumber"].ToString(); 525 } 526 return st; 527 } 528 529 530 /// <summary> 531 /// 主板型号 532 /// </summary> 533 public string GetBoardType() 534 { 535 string st = ""; 536 ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_BaseBoard"); 537 foreach (ManagementObject mo in mos.Get()) 538 { 539 st = mo["Product"].ToString(); 540 } 541 return st; 542 } 543 } 544 } 545 546 547 /* 548 * 在很多情况下,你可能都需要得到微机的硬件信息。比如:你想给你的软件加锁,不让别人随便访问。 549 550 551 最有效的办法是获取CPU的序列号,然后让你的软件只能运行在有这样的CPU序列号的机器上。众所周知,CPU序列号是唯一的!因此,这样就可以为你的软件加锁了。powered by 25175.net 552 553 554 另外一个需要硬盘信息的例子是:硬盘有几个分区,每个分区各有多少剩余空间。当你正在做一个多媒体应用程序的时候,你可能也需要获得有关声卡、显卡的硬件信息。 555 556 557 558 559 560 561 本应用程序另一个精彩的应用是:获取有关系统内存的信息,如内存地址,内存设备等等。 562 563 564 首先,你必须知道这个应用程序的功能是使用System.Management这个类得到的。因此,你需要加上下面的这句话: 565 566 567 using System.Management; 568 569 570 571 572 为了获取硬件信息,你还需要创建一个ManagementObjectSearcher 对象。 573 574 575 ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from " + Key); 576 577 578 // 硬件 579 Win32_Processor, // CPU 处理器 580 Win32_PhysicalMemory, // 物理内存条 581 Win32_Keyboard, // 键盘 582 Win32_PointingDevice, // 点输入设备,包括鼠标。 583 Win32_FloppyDrive, // 软盘驱动器 584 Win32_DiskDrive, // 硬盘驱动器 585 Win32_CDROMDrive, // 光盘驱动器 586 Win32_BaseBoard, // 主板 587 Win32_BIOS, // BIOS 芯片 588 Win32_ParallelPort, // 并口 589 Win32_SerialPort, // 串口 590 Win32_SerialPortConfiguration, // 串口配置 591 Win32_SoundDevice, // 多媒体设置,一般指声卡。 592 Win32_SystemSlot, // 主板插槽 (ISA & PCI & AGP) 593 Win32_USBController, // USB 控制器 594 Win32_NetworkAdapter, // 网络适配器 595 Win32_NetworkAdapterConfiguration, // 网络适配器设置 596 Win32_Printer, // 打印机 597 Win32_PrinterConfiguration, // 打印机设置 598 Win32_PrintJob, // 打印机任务 599 Win32_TCPIPPrinterPort, // 打印机端口 600 Win32_POTSModem, // MODEM 601 Win32_POTSModemToSerialPort, // MODEM 端口 602 Win32_DesktopMonitor, // 显示器 603 Win32_DisplayConfiguration, // 显卡 604 Win32_DisplayControllerConfiguration, // 显卡设置 605 Win32_VideoController, // 显卡细节。 606 Win32_VideoSettings, // 显卡支持的显示模式。 607 608 609 // 操作系统 610 Win32_TimeZone, // 时区 611 Win32_SystemDriver, // 驱动程序 612 Win32_DiskPartition, // 磁盘分区 613 Win32_LogicalDisk, // 逻辑磁盘 614 Win32_LogicalDiskToPartition, // 逻辑磁盘所在分区及始末位置。 615 Win32_LogicalMemoryConfiguration, // 逻辑内存配置 616 Win32_PageFile, // 系统页文件信息 617 Win32_PageFileSetting, // 页文件设置 618 Win32_BootConfiguration, // 系统启动配置 619 Win32_ComputerSystem, // 计算机信息简要 620 Win32_OperatingSystem, // 操作系统信息 621 Win32_StartupCommand, // 系统自动启动程序 622 Win32_Service, // 系统安装的服务 623 Win32_Group, // 系统管理组 624 Win32_GroupUser, // 系统组帐号 625 Win32_UserAccount, // 用户帐号 626 Win32_Process, // 系统进程 627 Win32_Thread, // 系统线程 628 Win32_Share, // 共享 629 Win32_NetworkClient, // 已安装的网络客户端 630 Win32_NetworkProtocol, // 已安装的网络协议 631 632 633 634 635 636 637 上面代码的Key是一个将被对应正确的数据填入的值。例如,获取CPU的信息,就需要把Key值设成Win32_Processor。所有Key可能的值,列举如下: 638 639 640 Win32_1394Controller 641 Win32_1394ControllerDevice 642 Win32_Account 643 Win32_AccountSID 644 Win32_ACE 645 Win32_ActionCheck 646 Win32_AllocatedResource 647 Win32_ApplicationCommandLine 648 Win32_ApplicationService 649 Win32_AssociatedBattery 650 Win32_AssociatedProcessorMemory 651 Win32_BaseBoard 652 Win32_BaseService 653 Win32_Battery 654 Win32_Binary 655 Win32_BindImageAction 656 Win32_BIOS 657 Win32_BootConfiguration 658 Win32_Bus 659 Win32_CacheMemory 660 Win32_CDROMDrive 661 Win32_CheckCheck 662 Win32_CIMLogicalDeviceCIMDataFile 663 Win32_ClassicCOMApplicationClasses 664 Win32_ClassicCOMClass 665 Win32_ClassicCOMClassSetting 666 Win32_ClassicCOMClassSettings 667 Win32_ClassInfoAction 668 Win32_ClientApplicationSetting 669 Win32_CodecFile 670 Win32_COMApplication 671 Win32_COMApplicationClasses 672 Win32_COMApplicationSettings 673 Win32_COMClass 674 Win32_ComClassAutoEmulator 675 Win32_ComClassEmulator 676 Win32_CommandLineAccess 677 Win32_ComponentCategory 678 Win32_ComputerSystem 679 Win32_ComputerSystemProcessor 680 Win32_ComputerSystemProduct 681 Win32_COMSetting 682 Win32_Condition 683 Win32_CreateFolderAction 684 Win32_CurrentProbe 685 Win32_DCOMApplication 686 Win32_DCOMApplicationAccessAllowedSetting 687 Win32_DCOMApplicationLaunchAllowedSetting 688 Win32_DCOMApplicationSetting 689 Win32_DependentService 690 Win32_Desktop 691 Win32_DesktopMonitor 692 Win32_DeviceBus 693 Win32_DeviceMemoryAddress 694 Win32_DeviceSettings 695 Win32_Directory 696 Win32_DirectorySpecification 697 Win32_DiskDrive 698 Win32_DiskDriveToDiskPartition 699 Win32_DiskPartition 700 Win32_DisplayConfiguration 701 Win32_DisplayControllerConfiguration 702 Win32_DMAChannel 703 Win32_DriverVXD 704 Win32_DuplicateFileAction 705 Win32_Environment 706 Win32_EnvironmentSpecification 707 Win32_ExtensionInfoAction 708 Win32_Fan 709 Win32_FileSpecification 710 Win32_FloppyController 711 Win32_FloppyDrive 712 Win32_FontInfoAction 713 Win32_Group 714 Win32_GroupUser 715 Win32_HeatPipe 716 Win32_IDEController 717 Win32_IDEControllerDevice 718 Win32_ImplementedCategory 719 Win32_InfraredDevice 720 Win32_IniFileSpecification 721 Win32_InstalledSoftwareElement 722 Win32_IRQResource 723 Win32_Keyboard 724 Win32_LaunchCondition 725 Win32_LoadOrderGroup 726 Win32_LoadOrderGroupServiceDependencies 727 Win32_LoadOrderGroupServiceMembers 728 Win32_LogicalDisk 729 Win32_LogicalDiskRootDirectory 730 Win32_LogicalDiskToPartition 731 Win32_LogicalFileAccess 732 Win32_LogicalFileAuditing 733 Win32_LogicalFileGroup 734 Win32_LogicalFileOwner 735 Win32_LogicalFileSecuritySetting 736 Win32_LogicalMemoryConfiguration 737 Win32_LogicalProgramGroup 738 Win32_LogicalProgramGroupDirectory 739 Win32_LogicalProgramGroupItem 740 Win32_LogicalProgramGroupItemDataFile 741 Win32_LogicalShareAccess 742 Win32_LogicalShareAuditing 743 Win32_LogicalShareSecuritySetting 744 Win32_ManagedSystemElementResource 745 Win32_MemoryArray 746 Win32_MemoryArrayLocation 747 Win32_MemoryDevice 748 Win32_MemoryDeviceArray 749 Win32_MemoryDeviceLocation 750 Win32_MethodParameterClass 751 Win32_MIMEInfoAction 752 Win32_MotherboardDevice 753 Win32_MoveFileAction 754 Win32_MSIResource 755 Win32_networkAdapter 756 Win32_networkAdapterConfiguration 757 Win32_networkAdapterSetting 758 Win32_networkClient 759 Win32_networkConnection 760 Win32_networkLoginProfile 761 Win32_networkProtocol 762 Win32_NTEventlogFile 763 Win32_NTLogEvent 764 Win32_NTLogEventComputer 765 Win32_NTLogEventLog 766 Win32_NTLogEventUser 767 Win32_ODBCAttribute 768 Win32_ODBCDataSourceAttribute 769 Win32_ODBCDataSourceSpecification 770 Win32_ODBCDriverAttribute 771 Win32_ODBCDriverSoftwareElement 772 Win32_ODBCDriverSpecification 773 Win32_ODBCSourceAttribute 774 Win32_ODBCTranslatorSpecification 775 Win32_OnBoardDevice 776 Win32_OperatingSystem 777 Win32_OperatingSystemQFE 778 Win32_OSRecoveryConfiguration 779 Win32_PageFile 780 Win32_PageFileElementSetting 781 Win32_PageFileSetting 782 Win32_PageFileUsage 783 Win32_ParallelPort 784 Win32_Patch 785 Win32_PatchFile 786 Win32_PatchPackage 787 Win32_PCMCIAController 788 Win32_Perf 789 Win32_PerfRawData 790 Win32_PerfRawData_ASP_ActiveServerPages 791 Win32_PerfRawData_ASPnet_114322_ASPnetAppsv114322 792 Win32_PerfRawData_ASPnet_114322_ASPnetv114322 793 Win32_PerfRawData_ASPnet_ASPnet 794 Win32_PerfRawData_ASPnet_ASPnetApplications 795 Win32_PerfRawData_IAS_IASAccountingClients 796 Win32_PerfRawData_IAS_IASAccountingServer 797 Win32_PerfRawData_IAS_IASAuthenticationClients 798 Win32_PerfRawData_IAS_IASAuthenticationServer 799 Win32_PerfRawData_InetInfo_InternetInformationServicesGlobal 800 Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator 801 Win32_PerfRawData_MSFTPSVC_FTPService 802 Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods 803 Win32_PerfRawData_MSSQLSERVER_SQLServerBackupDevice 804 Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager 805 Win32_PerfRawData_MSSQLSERVER_SQLServerBufferPartition 806 Win32_PerfRawData_MSSQLSERVER_SQLServerCacheManager 807 Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases 808 Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics 809 Win32_PerfRawData_MSSQLSERVER_SQLServerLatches 810 Win32_PerfRawData_MSSQLSERVER_SQLServerLocks 811 Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager 812 Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationAgents 813 Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationDist 814 Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationLogreader 815 Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationMerge 816 Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationSnapshot 817 Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics 818 Win32_PerfRawData_MSSQLSERVER_SQLServerUserSettable 819 Win32_PerfRawData_netFramework_netCLRExceptions 820 Win32_PerfRawData_netFramework_netCLRInterop 821 Win32_PerfRawData_netFramework_netCLRJit 822 Win32_PerfRawData_netFramework_netCLRLoading 823 Win32_PerfRawData_netFramework_netCLRLocksAndThreads 824 Win32_PerfRawData_netFramework_netCLRMemory 825 Win32_PerfRawData_netFramework_netCLRRemoting 826 Win32_PerfRawData_netFramework_netCLRSecurity 827 Win32_PerfRawData_Outlook_Outlook 828 Win32_PerfRawData_PerfDisk_PhysicalDisk 829 Win32_PerfRawData_Perfnet_Browser 830 Win32_PerfRawData_Perfnet_Redirector 831 Win32_PerfRawData_Perfnet_Server 832 Win32_PerfRawData_Perfnet_ServerWorkQueues 833 Win32_PerfRawData_PerfOS_Cache 834 Win32_PerfRawData_PerfOS_Memory 835 Win32_PerfRawData_PerfOS_Objects 836 Win32_PerfRawData_PerfOS_PagingFile 837 Win32_PerfRawData_PerfOS_Processor 838 Win32_PerfRawData_PerfOS_System 839 Win32_PerfRawData_PerfProc_FullImage_Costly 840 Win32_PerfRawData_PerfProc_Image_Costly 841 Win32_PerfRawData_PerfProc_JobObject 842 Win32_PerfRawData_PerfProc_JobObjectDetails 843 Win32_PerfRawData_PerfProc_Process 844 Win32_PerfRawData_PerfProc_ProcessAddressSpace_Costly 845 Win32_PerfRawData_PerfProc_Thread 846 Win32_PerfRawData_PerfProc_ThreadDetails_Costly 847 Win32_PerfRawData_RemoteAccess_RASPort 848 Win32_PerfRawData_RemoteAccess_RASTotal 849 Win32_PerfRawData_RSVP_ACSPerRSVPService 850 Win32_PerfRawData_Spooler_PrintQueue 851 Win32_PerfRawData_TapiSrv_Telephony 852 Win32_PerfRawData_Tcpip_ICMP 853 Win32_PerfRawData_Tcpip_IP 854 Win32_PerfRawData_Tcpip_NBTConnection 855 Win32_PerfRawData_Tcpip_networkInterface 856 Win32_PerfRawData_Tcpip_TCP 857 Win32_PerfRawData_Tcpip_UDP 858 Win32_PerfRawData_W3SVC_WebService 859 Win32_PhysicalMedia 860 Win32_PhysicalMemory 861 Win32_PhysicalMemoryArray 862 Win32_PhysicalMemoryLocation 863 Win32_PNPAllocatedResource 864 Win32_PnPDevice 865 Win32_PnPEntity 866 Win32_PointingDevice 867 Win32_PortableBattery 868 Win32_PortConnector 869 Win32_PortResource 870 Win32_POTSModem 871 Win32_POTSModemToSerialPort 872 Win32_PowerManagementEvent 873 Win32_Printer 874 Win32_PrinterConfiguration 875 Win32_PrinterController 876 Win32_PrinterDriverDll 877 Win32_PrinterSetting 878 Win32_PrinterShare 879 Win32_PrintJob 880 Win32_PrivilegesStatus 881 Win32_Process 882 Win32_Processor 883 Win32_ProcessStartup 884 Win32_Product 885 Win32_ProductCheck 886 Win32_ProductResource 887 Win32_ProductSoftwareFeatures 888 Win32_ProgIDSpecification 889 Win32_ProgramGroup 890 Win32_ProgramGroupContents 891 Win32_ProgramGroupOrItem 892 Win32_Property 893 Win32_ProtocolBinding 894 Win32_PublishComponentAction 895 Win32_QuickFixEngineering 896 Win32_Refrigeration 897 Win32_Registry 898 Win32_RegistryAction 899 Win32_RemoveFileAction 900 Win32_RemoveIniAction 901 Win32_ReserveCost 902 Win32_ScheduledJob 903 Win32_SCSIController 904 Win32_SCSIControllerDevice 905 Win32_SecurityDescriptor 906 Win32_SecuritySetting 907 Win32_SecuritySettingAccess 908 Win32_SecuritySettingAuditing 909 Win32_SecuritySettingGroup 910 Win32_SecuritySettingOfLogicalFile 911 Win32_SecuritySettingOfLogicalShare 912 Win32_SecuritySettingOfObject 913 Win32_SecuritySettingOwner 914 Win32_SelfRegModuleAction 915 Win32_SerialPort 916 Win32_SerialPortConfiguration 917 Win32_SerialPortSetting 918 Win32_Service 919 Win32_ServiceControl 920 Win32_ServiceSpecification 921 Win32_ServiceSpecificationService 922 Win32_SettingCheck 923 Win32_Share 924 Win32_ShareToDirectory 925 Win32_ShortcutAction 926 Win32_ShortcutFile 927 Win32_ShortcutSAP 928 Win32_SID 929 Win32_SMBIOSMemory 930 Win32_SoftwareElement 931 Win32_SoftwareElementAction 932 Win32_SoftwareElementCheck 933 Win32_SoftwareElementCondition 934 Win32_SoftwareElementResource 935 Win32_SoftwareFeature 936 Win32_SoftwareFeatureAction 937 Win32_SoftwareFeatureCheck 938 Win32_SoftwareFeatureParent 939 Win32_SoftwareFeatureSoftwareElements 940 Win32_SoundDevice 941 Win32_StartupCommand 942 Win32_SubDirectory 943 Win32_SystemAccount 944 Win32_SystemBIOS 945 Win32_SystemBootConfiguration 946 Win32_SystemDesktop 947 Win32_SystemDevices 948 Win32_SystemDriver 949 Win32_SystemDriverPNPEntity 950 Win32_SystemEnclosure 951 Win32_SystemLoadOrderGroups 952 Win32_SystemLogicalMemoryConfiguration 953 Win32_SystemMemoryResource 954 Win32_SystemnetworkConnections 955 Win32_SystemOperatingSystem 956 Win32_SystemPartitions 957 Win32_SystemProcesses 958 Win32_SystemProgramGroups 959 Win32_SystemResources 960 Win32_SystemServices 961 Win32_SystemSetting 962 Win32_SystemSlot 963 Win32_SystemSystemDriver 964 Win32_SystemTimeZone 965 Win32_SystemUsers 966 Win32_TapeDrive 967 Win32_TemperatureProbe 968 Win32_Thread 969 Win32_TimeZone 970 Win32_Trustee 971 Win32_TypeLibraryAction 972 Win32_UninterruptiblePowerSupply 973 Win32_USBController 974 Win32_USBControllerDevice 975 Win32_UserAccount 976 Win32_UserDesktop 977 Win32_VideoConfiguration 978 Win32_VideoController 979 Win32_VideoSettings 980 Win32_VoltageProbe 981 Win32_WMIElementSetting 982 Win32_WMISetting 983 984 985 986 987 首先,调用ManagementObjectSearcher实例(在本文中的例子里为searcher )中的Get()方法,该方法将会把返回信息填在这个实例中。然后,你所要做的就是处理这个实例searcher中的数据。 988 989 990 foreach (ManagementObject share in searcher.Get()){// Some Codes ...} 991 992 993 每个ManagementObject的对象中都有一些,我们所需要的数据,当然我们可以接着这么处理这些数据: 994 995 996 foreach (PropertyData PC in share.Properties){//some codes ...} 997 998 999 本文中代码的其它部分只是对于ListView控件的一些操作,很简单,就不再详述了! 1000 */
标签:type control 获取本地ip地址 ports console except software 调用 lis
原文地址:http://www.cnblogs.com/kuangwong/p/7289602.html