C#通过WMI获取系统信息
来源:互联网 发布:淘宝白银 编辑:程序博客网 时间:2024/06/11 09:52
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
Introduction
For numerous reasons, you may need to access system hardware information. One example is when you have created a software and you want to put a lock on that software.
One of the most efficient ways to do so is to get one of the IDs of a piece of hardware in the target machine and then plan your software so that it can just work with the computer that has the same ID. Since some hardware IDs (and not all of them) are unique, you have very simply created a lock!
Notice
In the first versions of this article, I thought that the Processor ID was unique, but some other users told me that they had tested the Processor ID in different computers and sometimes they give the same result. So you should consider this and not try to just rely on Processor ID. I suggest that you combine it with some other IDs such as Motherboard, USB Controller, Bios, CD-ROM Drive and so on.
Another example is the need to get hard disk information, its partitions, and the free space on each partition. You may also require the hardware information while working on a multimedia application when you need to have complete information about the sound device and the VGA device of the target machine. An excellent use of this application is getting information about the memory of the system and valuable information such as the device memory address, memory device and so on.
Using the Code
First of all, you have to know that the application function is using some System.Management
classes. So you need to add this line of code:
To get hardware information, you need to create an object of ManagementObjectSearcher
class.
The Key
on the code above, is a variable that is replaced with appropriate data. For example, to get the information of the CPU, you have to replace the Key
with Win32_Processor
. A complete list of these keys is given below:
First, call the Get()
method of the ManagementObjectSearcher
object that this application calls the searcher
object. This will fill the object with the information you need. After that, you need to process the data that is in the searcher
object.
Each ManagementObject
has some Properties that are useful for us. Of course the Data of those properties is needed and we can process them like this:
The other parts of this application are nothing but working with the ListView
control and that is really easy!
- C#通过WMI获取系统信息
- 通过WMI获取系统信息
- 通过WMI获取系统信息
- 通过WMI获取系统信息
- 【收藏】通过 WMI 获取系统信息
- Delphi通过WMI获取系统信息
- 编程通过WMI获取系统信息
- C++ Builder 通过 WMI 获取系统信息
- WMI获取系统信息
- C#中通过wmi获取硬件的信息
- 通过WMI获取主板信息
- 关于C#中用WMI获取系统信息问题
- 使用WMI获取系统信息
- 使用WMI获取系统信息
- C#,WMI获取系统信息
- 通过WMI获取系统IP
- 【WMI】WMI For C#/dotNet 用WMI获取系统信息
- C/C++通过WMI和系统API函数获取获取系统硬件配置信息
- 【转】一个程序员对学弟学妹建议
- 机器人 discovery
- oracle 索引失效、创建及重建
- 关于CClientDC与CPAINTDC,以及GetDC与GetWindowDC的用法。
- OGRE中对象的内存分配[转]
- C#通过WMI获取系统信息
- Oracle 查看用户权限以及索引
- Redhat Linux oracle 10g em 按钮乱码解决
- 邹涛
- 替换js双引号、斜杠
- 支付宝及时到帐接口使用详解
- 在google map中创建自定义控件
- [Error] MainFrm.pas(107): Incompatible types: 'MAPGISMAPCOMLib_TLB.IMap' and 'EDITVIEWLib_TLB.IMap'
- OGRE地形配置文件解析