使用。net的ManagementClass获取计算机硬件信息
1. ManagementClass osClass = new ManagementClass("Win32_MemoryDevice");//这里写的是内存的信息,可以改成如下的信息
2. //Win32_1394Controller
3. //Win32_1394ControllerDevice
4. //Win32_Account
5. //Win32_AccountSID
6. //Win32_ACE
7. //Win32_ActionCheck
8. //Win32_AllocatedResource
9. //Win32_ApplicationCommandLine
10. //Win32_ApplicationService
11. //Win32_AssociatedBattery
12. //Win32_AssociatedProcessorMemory
13. //Win32_BaseBoard
14. //Win32_BaseService
15. //Win32_Battery
16. //Win32_Binary
17. //Win32_BindImageAction
18. //Win32_BIOS
19. //Win32_BootConfiguration
20. //Win32_Bus
21. //Win32_CacheMemory
22. //Win32_CDROMDrive
23. //Win32_CheckCheck
24. //Win32_CIMLogicalDeviceCIMDataFile
25. //Win32_ClassicCOMApplicationClasses
26. //Win32_ClassicCOMClass
27. //Win32_ClassicCOMClassSetting
28. //Win32_ClassicCOMClassSettings
29. //Win32_ClassInfoAction
30. //Win32_ClientApplicationSetting
31. //Win32_CodecFile
32. //Win32_COMApplication
33. //Win32_COMApplicationClasses
34. //Win32_COMApplicationSettings
35. //Win32_COMClass
36. //Win32_ComClassAutoEmulator
37. //Win32_ComClassEmulator
38. //Win32_CommandLineAccess
39. //Win32_ComponentCategory
40. //Win32_ComputerSystem
41. //Win32_ComputerSystemProcessor
42. //Win32_ComputerSystemProduct
43. //Win32_COMSetting
44. //Win32_Condition
45. //Win32_CreateFolderAction
46. //Win32_CurrentProbe
47. //Win32_DCOMApplication
48. //Win32_DCOMApplicationAccessAllowedSetting
49. //Win32_DCOMApplicationLaunchAllowedSetting
50. //Win32_DCOMApplicationSetting
51. //Win32_DependentService
52. //Win32_Desktop
53. //Win32_DesktopMonitor
54. //Win32_DeviceBus
55. //Win32_DeviceMemoryAddress
56. //Win32_DeviceSettings
57. //Win32_Directory
58. //Win32_DirectorySpecification
59. //Win32_DiskDrive-----------------------硬盘驱动信息
60. //Win32_DiskDriveToDiskPartition
61. //Win32_DiskPartition
62. //Win32_DisplayConfiguration
63. //Win32_DisplayControllerConfiguration
64. //Win32_DMAChannel
65. //Win32_DriverVXD
66. //Win32_DuplicateFileAction
67. //Win32_Environment
68. //Win32_EnvironmentSpecification
69. //Win32_ExtensionInfoAction
70. //Win32_Fan
71. //Win32_FileSpecification
72. //Win32_FloppyController
73. //Win32_FloppyDrive
74. //Win32_FontInfoAction
75. //Win32_Group
76. //Win32_GroupUser
77. //Win32_HeatPipe
78. //Win32_IDEController
79. //Win32_IDEControllerDevice
80. //Win32_ImplementedCategory
81. //Win32_InfraredDevice
82. //Win32_IniFileSpecification
83. //Win32_InstalledSoftwareElement
84. //Win32_IRQResource
85. //Win32_Keyboard
86. //Win32_LaunchCondition
87. //Win32_LoadOrderGroup
88. //Win32_LoadOrderGroupServiceDependencies
89. //Win32_LoadOrderGroupServiceMembers
90. //Win32_LogicalDisk
91. //Win32_LogicalDiskRootDirectory
92. //Win32_LogicalDiskToPartition
93. //Win32_LogicalFileAccess
94. //Win32_LogicalFileAuditing
95. //Win32_LogicalFileGroup
96. //Win32_LogicalFileOwner
97. //Win32_LogicalFileSecuritySetting
98. //Win32_LogicalMemoryConfiguration
99. //Win32_LogicalProgramGroup
100. //Win32_LogicalProgramGroupDirectory
101. //Win32_LogicalProgramGroupItem
102. //Win32_LogicalProgramGroupItemDataFile
103. //Win32_LogicalShareAccess
104. //Win32_LogicalShareAuditing
105. //Win32_LogicalShareSecuritySetting
106. //Win32_ManagedSystemElementResource
107. //Win32_MemoryArray
108. //Win32_MemoryArrayLocation
109. //Win32_MemoryDevice
110. //Win32_MemoryDeviceArray
111. //Win32_MemoryDeviceLocation
112. //Win32_MethodParameterClass
113. //Win32_MIMEInfoAction
114. //Win32_MotherboardDevice
115. //Win32_MoveFileAction
116. //Win32_MSIResource
117. //Win32_NetworkAdapter
118. //Win32_NetworkAdapterConfiguration
119. //Win32_NetworkAdapterSetting
120. //Win32_NetworkClient
121. //Win32_NetworkConnection
122. //Win32_NetworkLoginProfile
123. //Win32_NetworkProtocol
124. //Win32_NTEventlogFile
125. //Win32_NTLogEvent
126. //Win32_NTLogEventComputer
127. //Win32_NTLogEventLog
128. //Win32_NTLogEventUser
129. //Win32_ODBCAttribute
130. //Win32_ODBCDataSourceAttribute
131. //Win32_ODBCDataSourceSpecification
132. //Win32_ODBCDriverAttribute
133. //Win32_ODBCDriverSoftwareElement
134. //Win32_ODBCDriverSpecification
135. //Win32_ODBCSourceAttribute
136. //Win32_ODBCTranslatorSpecification
137. //Win32_OnBoardDevice
138. //Win32_OperatingSystem
139. //Win32_OperatingSystemQFE
140. //Win32_OSRecoveryConfiguration
141. //Win32_PageFile
142. //Win32_PageFileElementSetting
143. //Win32_PageFileSetting
144. //Win32_PageFileUsage
145. //Win32_ParallelPort
146. //Win32_Patch
147. //Win32_PatchFile
148. //Win32_PatchPackage
149. //Win32_PCMCIAController
150. //Win32_Perf
151. //Win32_PerfRawData
152. //Win32_PerfRawData_ASP_ActiveServerPages
153. //Win32_PerfRawData_ASPNET_114322_ASPNETAppsv114322
154. //Win32_PerfRawData_ASPNET_114322_ASPNETv114322
155. //Win32_PerfRawData_ASPNET_ASPNET
156. //Win32_PerfRawData_ASPNET_ASPNETApplications
157. //Win32_PerfRawData_IAS_IASAccountingClients
158. //Win32_PerfRawData_IAS_IASAccountingServer
159. //Win32_PerfRawData_IAS_IASAuthenticationClients
160. //Win32_PerfRawData_IAS_IASAuthenticationServer
161. //Win32_PerfRawData_InetInfo_InternetInformationServicesGlobal
162. //Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator
163. //Win32_PerfRawData_MSFTPSVC_FTPService
164. //Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods
165. //Win32_PerfRawData_MSSQLSERVER_SQLServerBackupDevice
166. //Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager
167. //Win32_PerfRawData_MSSQLSERVER_SQLServerBufferPartition
168. //Win32_PerfRawData_MSSQLSERVER_SQLServerCacheManager
169. //Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases
170. //Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics
171. //Win32_PerfRawData_MSSQLSERVER_SQLServerLatches
172. //Win32_PerfRawData_MSSQLSERVER_SQLServerLocks
173. //Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager
174. //Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationAgents
175. //Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationDist
176. //Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationLogreader
177. //Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationMerge
178. //Win32_PerfRawData_MSSQLSERVER_SQLServerReplicationSnapshot
179. //Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics
180. //Win32_PerfRawData_MSSQLSERVER_SQLServerUserSettable
181. //Win32_PerfRawData_NETFramework_NETCLRExceptions
182. //Win32_PerfRawData_NETFramework_NETCLRInterop
183. //Win32_PerfRawData_NETFramework_NETCLRJit
184. //Win32_PerfRawData_NETFramework_NETCLRLoading
185. //Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads
186. //Win32_PerfRawData_NETFramework_NETCLRMemory
187. //Win32_PerfRawData_NETFramework_NETCLRRemoting
188. //Win32_PerfRawData_NETFramework_NETCLRSecurity
189. //Win32_PerfRawData_Outlook_Outlook
190. //Win32_PerfRawData_PerfDisk_PhysicalDisk
191. //Win32_PerfRawData_PerfNet_Browser
192. //Win32_PerfRawData_PerfNet_Redirector
193. //Win32_PerfRawData_PerfNet_Server
194. //Win32_PerfRawData_PerfNet_ServerWorkQueues
195. //Win32_PerfRawData_PerfOS_Cache
196. //Win32_PerfRawData_PerfOS_Memory
197. //Win32_PerfRawData_PerfOS_Objects
198. //Win32_PerfRawData_PerfOS_PagingFile
199. //Win32_PerfRawData_PerfOS_Processor
200. //Win32_PerfRawData_PerfOS_System
201. //Win32_PerfRawData_PerfProc_FullImage_Costly
202. //Win32_PerfRawData_PerfProc_Image_Costly
203. //Win32_PerfRawData_PerfProc_JobObject
204. //Win32_PerfRawData_PerfProc_JobObjectDetails
205. //Win32_PerfRawData_PerfProc_Process
206. //Win32_PerfRawData_PerfProc_ProcessAddressSpace_Costly
207. //Win32_PerfRawData_PerfProc_Thread
208. //Win32_PerfRawData_PerfProc_ThreadDetails_Costly
209. //Win32_PerfRawData_RemoteAccess_RASPort
210. //Win32_PerfRawData_RemoteAccess_RASTotal
211. //Win32_PerfRawData_RSVP_ACSPerRSVPService
212. //Win32_PerfRawData_Spooler_PrintQueue
213. //Win32_PerfRawData_TapiSrv_Telephony
214. //Win32_PerfRawData_Tcpip_ICMP
215. //Win32_PerfRawData_Tcpip_IP
216. //Win32_PerfRawData_Tcpip_NBTConnection
217. //Win32_PerfRawData_Tcpip_NetworkInterface
218. //Win32_PerfRawData_Tcpip_TCP
219. //Win32_PerfRawData_Tcpip_UDP
220. //Win32_PerfRawData_W3SVC_WebService
221. //Win32_PhysicalMemory
222. //Win32_PhysicalMemoryArray
223. //Win32_PhysicalMemoryLocation
224. //Win32_PNPAllocatedResource
225. //Win32_PnPDevice
226. //Win32_PnPEntity
227. //Win32_PointingDevice
228. //Win32_PortableBattery
229. //Win32_PortConnector
230. //Win32_PortResource
231. //Win32_POTSModem
232. //Win32_POTSModemToSerialPort
233. //Win32_PowerManagementEvent
234. //Win32_Printer
235. //Win32_PrinterConfiguration
236. //Win32_PrinterController
237. //Win32_PrinterDriverDll
238. //Win32_PrinterSetting
239. //Win32_PrinterShare
240. //Win32_PrintJob
241. //Win32_PrivilegesStatus
242. //Win32_Process
243. //Win32_Processor--------------------cup信息
244. //Win32_ProcessStartup
245. //Win32_Product
246. //Win32_ProductCheck
247. //Win32_ProductResource
248. //Win32_ProductSoftwareFeatures
249. //Win32_ProgIDSpecification
250. //Win32_ProgramGroup
251. //Win32_ProgramGroupContents
252. //Win32_ProgramGroupOrItem
253. //Win32_Property
254. //Win32_ProtocolBinding
255. //Win32_PublishComponentAction
256. //Win32_QuickFixEngineering
257. //Win32_Refrigeration
258. //Win32_Registry
259. //Win32_RegistryAction
260. //Win32_RemoveFileAction
261. //Win32_RemoveIniAction
262. //Win32_ReserveCost
263. //Win32_ScheduledJob
264. //Win32_SCSIController
265. //Win32_SCSIControllerDevice
266. //Win32_SecurityDescriptor
267. //Win32_SecuritySetting
268. //Win32_SecuritySettingAccess
269. //Win32_SecuritySettingAuditing
270. //Win32_SecuritySettingGroup
271. //Win32_SecuritySettingOfLogicalFile
272. //Win32_SecuritySettingOfLogicalShare
273. //Win32_SecuritySettingOfObject
274. //Win32_SecuritySettingOwner
275. //Win32_SelfRegModuleAction
276. //Win32_SerialPort
277. //Win32_SerialPortConfiguration
278. //Win32_SerialPortSetting
279. //Win32_Service
280. //Win32_ServiceControl
281. //Win32_ServiceSpecification
282. //Win32_ServiceSpecificationService
283. //Win32_SettingCheck
284. //Win32_Share
285. //Win32_ShareToDirectory
286. //Win32_ShortcutAction
287. //Win32_ShortcutFile
288. //Win32_ShortcutSAP
289. //Win32_SID
290. //Win32_SMBIOSMemory
291. //Win32_SoftwareElement
292. //Win32_SoftwareElementAction
293. //Win32_SoftwareElementCheck
294. //Win32_SoftwareElementCondition
295. //Win32_SoftwareElementResource
296. //Win32_SoftwareFeature
297. //Win32_SoftwareFeatureAction
298. //Win32_SoftwareFeatureCheck
299. //Win32_SoftwareFeatureParent
300. //Win32_SoftwareFeatureSoftwareElements
301. //Win32_SoundDevice
302. //Win32_StartupCommand
303. //Win32_SubDirectory
304. //Win32_SystemAccount
305. //Win32_SystemBIOS
306. //Win32_SystemBootConfiguration
307. //Win32_SystemDesktop
308. //Win32_SystemDevices
309. //Win32_SystemDriver
310. //Win32_SystemDriverPNPEntity
311. //Win32_SystemEnclosure
312. //Win32_SystemLoadOrderGroups
313. //Win32_SystemLogicalMemoryConfiguration
314. //Win32_SystemMemoryResource
315. //Win32_SystemNetworkConnections
316. //Win32_SystemOperatingSystem
317. //Win32_SystemPartitions
318. //Win32_SystemProcesses
319. //Win32_SystemProgramGroups
320. //Win32_SystemResources
321. //Win32_SystemServices
322. //Win32_SystemSetting
323. //Win32_SystemSlot
324. //Win32_SystemSystemDriver
325. //Win32_SystemTimeZone
326. //Win32_SystemUsers
327. //Win32_TapeDrive
328. //Win32_TemperatureProbe
329. //Win32_Thread
330. //Win32_TimeZone
331. //Win32_Trustee
332. //Win32_TypeLibraryAction
333. //Win32_UninterruptiblePowerSupply
334. //Win32_USBController
335. //Win32_USBControllerDevice
336. //Win32_UserAccount
337. //Win32_UserDesktop
338. //Win32_VideoConfiguration
339. //Win32_VideoController
340. //Win32_VideoSettings
341. //Win32_VoltageProbe
342. //Win32_WMIElementSetting
343. //Win32_WMISetting
344. osClass.Options.UseAmendedQualifiers = true;
345. PropertyDataCollection properties = osClass.Properties;
346. foreach (PropertyData property in properties)
347. {
348. Response.Write("<br/>");
349. Response.Write("---------------------------start--------------------------------<br/>");
350. Response.Write("属性名称: " + property.Name + "<br/>");
351. Response.Write("属性描述: " + property.Qualifiers["Description"].Value + "<br/>");
352. Response.Write("属性类型: " + property.Type + "<br/>");
353. // Response.Write("Qualifiers: ");
354. //foreach (QualifierData q in property.Qualifiers)
355. //{
356. // Response.Write(q.Name);
357. //}
358. // Response.Write();
359. foreach (ManagementObject c in osClass.GetInstances())
360. {
361. Response.Write("属性值: " + c.Properties[property.Name.ToString()].Value + "<br/>");
362. }
363. Response.Write("-----------------------------end---------------------------------<br/>");
364. Response.Write("<br/>");
365. }