How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
来源:互联网 发布:哪些crm软件免费 编辑:程序博客网 时间:2024/05/04 23:13
http://www.codeproject.com/KB/system/GetHardwareInformation.aspx
- Download source code - 15.9 KB
- Download project demo - 14.6 KB
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:
using System.Management;
To get hardware information, you need to create an object of ManagementObjectSearcher
class.
ManagementObjectSearcher searcher = new ManagementObjectSearcher( "select * from " + Key);
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:
Win32_1394ControllerWin32_1394ControllerDeviceWin32_AccountWin32_AccountSIDWin32_ACEWin32_ActionCheckWin32_AllocatedResourceWin32_ApplicationCommandLineWin32_ApplicationServiceWin32_AssociatedBatteryWin32_AssociatedProcessorMemoryWin32_BaseBoardWin32_BaseServiceWin32_BatteryWin32_BinaryWin32_BindImageActionWin32_BIOSWin32_BootConfigurationWin32_BusWin32_CacheMemoryWin32_CDROMDriveWin32_CheckCheckWin32_CIMLogicalDeviceCIMDataFileWin32_ClassicCOMApplicationClassesWin32_ClassicCOMClassWin32_ClassicCOMClassSettingWin32_ClassicCOMClassSettingsWin32_ClassInfoActionWin32_ClientApplicationSettingWin32_CodecFileWin32_COMApplicationWin32_COMApplicationClassesWin32_COMApplicationSettingsWin32_COMClassWin32_ComClassAutoEmulatorWin32_ComClassEmulatorWin32_CommandLineAccessWin32_ComponentCategoryWin32_ComputerSystemWin32_ComputerSystemProcessorWin32_ComputerSystemProductWin32_COMSettingWin32_ConditionWin32_CreateFolderActionWin32_CurrentProbeWin32_DCOMApplicationWin32_DCOMApplicationAccessAllowedSettingWin32_DCOMApplicationLaunchAllowedSettingWin32_DCOMApplicationSettingWin32_DependentServiceWin32_DesktopWin32_DesktopMonitorWin32_DeviceBusWin32_DeviceMemoryAddressWin32_DeviceSettingsWin32_DirectoryWin32_DirectorySpecificationWin32_DiskDriveWin32_DiskDriveToDiskPartitionWin32_DiskPartitionWin32_DisplayConfigurationWin32_DisplayControllerConfigurationWin32_DMAChannelWin32_DriverVXDWin32_DuplicateFileActionWin32_EnvironmentWin32_EnvironmentSpecificationWin32_ExtensionInfoActionWin32_FanWin32_FileSpecificationWin32_FloppyControllerWin32_FloppyDriveWin32_FontInfoActionWin32_GroupWin32_GroupUserWin32_HeatPipeWin32_IDEControllerWin32_IDEControllerDeviceWin32_ImplementedCategoryWin32_InfraredDeviceWin32_IniFileSpecificationWin32_InstalledSoftwareElementWin32_IRQResourceWin32_KeyboardWin32_LaunchConditionWin32_LoadOrderGroupWin32_LoadOrderGroupServiceDependenciesWin32_LoadOrderGroupServiceMembersWin32_LogicalDiskWin32_LogicalDiskRootDirectoryWin32_LogicalDiskToPartitionWin32_LogicalFileAccessWin32_LogicalFileAuditingWin32_LogicalFileGroupWin32_LogicalFileOwnerWin32_LogicalFileSecuritySettingWin32_LogicalMemoryConfigurationWin32_LogicalProgramGroupWin32_LogicalProgramGroupDirectoryWin32_LogicalProgramGroupItemWin32_LogicalProgramGroupItemDataFileWin32_LogicalShareAccessWin32_LogicalShareAuditingWin32_LogicalShareSecuritySettingWin32_ManagedSystemElementResourceWin32_MemoryArrayWin32_MemoryArrayLocationWin32_MemoryDeviceWin32_MemoryDeviceArrayWin32_MemoryDeviceLocationWin32_MethodParameterClassWin32_MIMEInfoActionWin32_MotherboardDeviceWin32_MoveFileActionWin32_MSIResourceWin32_NetworkAdapterWin32_NetworkAdapterConfigurationWin32_NetworkAdapterSettingWin32_NetworkClientWin32_NetworkConnectionWin32_NetworkLoginProfileWin32_NetworkProtocolWin32_NTEventlogFileWin32_NTLogEventWin32_NTLogEventComputerWin32_NTLogEventLogWin32_NTLogEventUserWin32_ODBCAttributeWin32_ODBCDataSourceAttributeWin32_ODBCDataSourceSpecificationWin32_ODBCDriverAttributeWin32_ODBCDriverSoftwareElementWin32_ODBCDriverSpecificationWin32_ODBCSourceAttributeWin32_ODBCTranslatorSpecificationWin32_OnBoardDeviceWin32_OperatingSystemWin32_OperatingSystemQFEWin32_OSRecoveryConfigurationWin32_PageFileWin32_PageFileElementSettingWin32_PageFileSettingWin32_PageFileUsageWin32_ParallelPortWin32_PatchWin32_PatchFileWin32_PatchPackageWin32_PCMCIAControllerWin32_PerfWin32_PerfRawDataWin32_PerfRawData_ASP_ActiveServerPagesWin32_PerfRawData_ASPNET_114322_ASPNETAppsv114322Win32_PerfRawData_ASPNET_114322_ASPNETv114322Win32_PerfRawData_ASPNET_ASPNETWin32_PerfRawData_ASPNET_ASPNETApplicationsWin32_PerfRawData_IAS_IASAccountingClientsWin32_PerfRawData_IAS_IASAccountingServerWin32_PerfRawData_IAS_IASAuthenticationClientsWin32_PerfRawData_IAS_IASAuthenticationServerWin32_PerfRawData_InetInfo_InternetInformationServicesGlobalWin32_PerfRawData_MSDTC_DistributedTransactionCoordinatorWin32_PerfRawData_MSFTPSVC_FTPServiceWin32_PerfRawData_MSSQLSERVER_SQLServerAccessMethodsWin32_PerfRawData_MSSQLSERVER_SQLServerBackupDeviceWin32_PerfRawData_MSSQLSERVER_SQLServerBufferManagerWin32_PerfRawData_MSSQLSERVER_SQLServerBufferPartitionWin32_PerfRawData_MSSQLSERVER_SQLServerCacheManagerWin32_PerfRawData_MSSQLSERVER_SQLServerDatabasesWin32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatisticsWin32_PerfRawData_MSSQLSERVER_SQLServerLatchesWin32_PerfRawData_MSSQLSERVER_SQLServerLocksWin32_PerfRawData_MSSQLSERVER_SQLServerMemoryManagerWin32_PerfRawData_MSSQLSERVER_SQLServerReplicationAgentsWin32_PerfRawData_MSSQLSERVER_SQLServerReplicationDistWin32_PerfRawData_MSSQLSERVER_SQLServerReplicationLogreaderWin32_PerfRawData_MSSQLSERVER_SQLServerReplicationMergeWin32_PerfRawData_MSSQLSERVER_SQLServerReplicationSnapshotWin32_PerfRawData_MSSQLSERVER_SQLServerSQLStatisticsWin32_PerfRawData_MSSQLSERVER_SQLServerUserSettableWin32_PerfRawData_NETFramework_NETCLRExceptionsWin32_PerfRawData_NETFramework_NETCLRInteropWin32_PerfRawData_NETFramework_NETCLRJitWin32_PerfRawData_NETFramework_NETCLRLoadingWin32_PerfRawData_NETFramework_NETCLRLocksAndThreadsWin32_PerfRawData_NETFramework_NETCLRMemoryWin32_PerfRawData_NETFramework_NETCLRRemotingWin32_PerfRawData_NETFramework_NETCLRSecurityWin32_PerfRawData_Outlook_OutlookWin32_PerfRawData_PerfDisk_PhysicalDiskWin32_PerfRawData_PerfNet_BrowserWin32_PerfRawData_PerfNet_RedirectorWin32_PerfRawData_PerfNet_ServerWin32_PerfRawData_PerfNet_ServerWorkQueuesWin32_PerfRawData_PerfOS_CacheWin32_PerfRawData_PerfOS_MemoryWin32_PerfRawData_PerfOS_ObjectsWin32_PerfRawData_PerfOS_PagingFileWin32_PerfRawData_PerfOS_ProcessorWin32_PerfRawData_PerfOS_SystemWin32_PerfRawData_PerfProc_FullImage_CostlyWin32_PerfRawData_PerfProc_Image_CostlyWin32_PerfRawData_PerfProc_JobObjectWin32_PerfRawData_PerfProc_JobObjectDetailsWin32_PerfRawData_PerfProc_ProcessWin32_PerfRawData_PerfProc_ProcessAddressSpace_CostlyWin32_PerfRawData_PerfProc_ThreadWin32_PerfRawData_PerfProc_ThreadDetails_CostlyWin32_PerfRawData_RemoteAccess_RASPortWin32_PerfRawData_RemoteAccess_RASTotalWin32_PerfRawData_RSVP_ACSPerRSVPServiceWin32_PerfRawData_Spooler_PrintQueueWin32_PerfRawData_TapiSrv_TelephonyWin32_PerfRawData_Tcpip_ICMPWin32_PerfRawData_Tcpip_IPWin32_PerfRawData_Tcpip_NBTConnectionWin32_PerfRawData_Tcpip_NetworkInterfaceWin32_PerfRawData_Tcpip_TCPWin32_PerfRawData_Tcpip_UDPWin32_PerfRawData_W3SVC_WebServiceWin32_PhysicalMemoryWin32_PhysicalMemoryArrayWin32_PhysicalMemoryLocationWin32_PNPAllocatedResourceWin32_PnPDeviceWin32_PnPEntityWin32_PointingDeviceWin32_PortableBatteryWin32_PortConnectorWin32_PortResourceWin32_POTSModemWin32_POTSModemToSerialPortWin32_PowerManagementEventWin32_PrinterWin32_PrinterConfigurationWin32_PrinterControllerWin32_PrinterDriverDllWin32_PrinterSettingWin32_PrinterShareWin32_PrintJobWin32_PrivilegesStatusWin32_ProcessWin32_ProcessorWin32_ProcessStartupWin32_ProductWin32_ProductCheckWin32_ProductResourceWin32_ProductSoftwareFeaturesWin32_ProgIDSpecificationWin32_ProgramGroupWin32_ProgramGroupContentsWin32_ProgramGroupOrItemWin32_PropertyWin32_ProtocolBindingWin32_PublishComponentActionWin32_QuickFixEngineeringWin32_RefrigerationWin32_RegistryWin32_RegistryActionWin32_RemoveFileActionWin32_RemoveIniActionWin32_ReserveCostWin32_ScheduledJobWin32_SCSIControllerWin32_SCSIControllerDeviceWin32_SecurityDescriptorWin32_SecuritySettingWin32_SecuritySettingAccessWin32_SecuritySettingAuditingWin32_SecuritySettingGroupWin32_SecuritySettingOfLogicalFileWin32_SecuritySettingOfLogicalShareWin32_SecuritySettingOfObjectWin32_SecuritySettingOwnerWin32_SelfRegModuleActionWin32_SerialPortWin32_SerialPortConfigurationWin32_SerialPortSettingWin32_ServiceWin32_ServiceControlWin32_ServiceSpecificationWin32_ServiceSpecificationServiceWin32_SettingCheckWin32_ShareWin32_ShareToDirectoryWin32_ShortcutActionWin32_ShortcutFileWin32_ShortcutSAPWin32_SIDWin32_SMBIOSMemoryWin32_SoftwareElementWin32_SoftwareElementActionWin32_SoftwareElementCheckWin32_SoftwareElementConditionWin32_SoftwareElementResourceWin32_SoftwareFeatureWin32_SoftwareFeatureActionWin32_SoftwareFeatureCheckWin32_SoftwareFeatureParentWin32_SoftwareFeatureSoftwareElementsWin32_SoundDeviceWin32_StartupCommandWin32_SubDirectoryWin32_SystemAccountWin32_SystemBIOSWin32_SystemBootConfigurationWin32_SystemDesktopWin32_SystemDevicesWin32_SystemDriverWin32_SystemDriverPNPEntityWin32_SystemEnclosureWin32_SystemLoadOrderGroupsWin32_SystemLogicalMemoryConfigurationWin32_SystemMemoryResourceWin32_SystemNetworkConnectionsWin32_SystemOperatingSystemWin32_SystemPartitionsWin32_SystemProcessesWin32_SystemProgramGroupsWin32_SystemResourcesWin32_SystemServicesWin32_SystemSettingWin32_SystemSlotWin32_SystemSystemDriverWin32_SystemTimeZoneWin32_SystemUsersWin32_TapeDriveWin32_TemperatureProbeWin32_ThreadWin32_TimeZoneWin32_TrusteeWin32_TypeLibraryActionWin32_UninterruptiblePowerSupplyWin32_USBControllerWin32_USBControllerDeviceWin32_UserAccountWin32_UserDesktopWin32_VideoConfigurationWin32_VideoControllerWin32_VideoSettingsWin32_VoltageProbeWin32_WMIElementSettingWin32_WMISetting
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.
foreach (ManagementObject share in searcher.Get()){// Some Codes ...}
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:
foreach (PropertyData PC in share.Properties){ //some codes ...}
The other parts of this application are nothing but working with the ListView
control and that is really easy!
- How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
- How to Get Hardware Information using C#
- Sample to get CPU information
- How to check system information
- how to get session information
- using powershell to check the hard disk information
- get hardware information using c#
- How to Get CPU Information on Android Android上获取cpu信息
- How to get CListCtrl clicked item information !!
- How to get information of .a/.so
- How to get user information say: passwd
- How to get the Information leakage
- Linux Command To Find the System Configuration And Hardware Information
- Linux Command To Find the System Configuration And Hardware Information
- Get System Drives Information
- Get Android System Information
- How To Get System Info In Linux
- [PHP]How to get the system info?
- COM域名再现两大风险 网络安全敲响警钟
- 利用 HttpClient 实现 WI/SSO 中的 Eager Sign in
- 考研,计算机
- 原来我不会SQL
- 有关排序-稳定-时间性能(转)
- How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
- 如何找到起始目录的绝对路径名
- C++多态技术
- 5.2.3 lockf 文件控制
- 传智播客我的SqlServer脚本--很全面哦!
- Linux下安装boost
- 要学习的东西还很多
- EBS常用数据表
- codedom 需要解决的问题