Using WMI to obtain computer information WMI is an industry recommendation specification designed to develop a standardized technology to access management information in the enterprise environment. This information includes the system memory status, the list of currently installed customer applications, and other data about the client status. WMI is a scalable system management structure. This specification uses a unified, standard-based, and scalable object-oriented interface. It provides a standard way to interact with system administrators and basic WMI APIs. It is mainly used by system management application developers and system administrators to access and manage operating system information. WMI can be used to generate tools for organizing and managing system information so that system administrators can monitor system activities more closely. WMI provides a rich set of system management services built into the Microsoft Windows operating system, A large number of applications, services, and devices are now used to provide comprehensive management functions for information technology operations and product support organizations. The use of WMI-based management systems provides a more reliable computing environment and higher system reliability, thus saving the cost of the enterprise. WMI provides a large number of specifications for many high-end applications, such as Microsoft Exchange, Microsoft SQL Server, and Microsoft Internet Information Service (IIS) to implement the following management tasks. 1. monitor application running status 2. detect bottlenecks or faults 3. manage and configure applications 4. query application data (using object link traversal and query) 5. to perform seamless local or remote management operations, we use an example to describe the power of WMI. Use VB6 as the column: Reference "Microsoft WMI scripting V1.1 library" Code as follows: Option explicitdim withevents sink as swbemsinkdim J as integer 'function: Use the WMI component to obtain computer information, each small function is written separately, so that you can refer to private sub cmddone_click () dim owminamespace as your ologicaldiskset as your ologicaldisk as swbemobject dim objset as variantdim sdrive as stringdim svalue as stringdim dblsize as doubledim OBJ as variant dim lindex as long Set owminamespace = GetObject ("winmgmts:") 'to obtain the drive information. On Error resume nextset objset = owminamespace. instancesof ("win32_diskdrive") for each OBJ in objset list5.additem obj. caption & "-" & bytestomegabytes (obj. size) & "GB" Next "Get the detailed information of each drive on error goto errorhandler 'set owminamespace = GetObject (" winmgmts: ") set ologicaldiskset = owminamespace. instancesof ("win32_logicaldisk") for each ologicaldis K In ologicaldiskset on error resume next sdrive = ologicaldisk. deviceID listview1.listitems. add, sdrive lindex = listview1.listitems. count svalue = ologicaldisk. description & "" listview1.listitems (lindex ). subitems (1) = svalue = ologicaldisk. filesystem & "" listview1.listitems (lindex ). subitems (2) = svalue = ologicaldisk. volumename & "" listview1.listitems (lindex ). subitems (3) = SV Alue svalue = ologicaldisk. volumeserialnumber & "" listview1.listitems (lindex ). subitems (4) = svalue = ologicaldisk. size & "" If isnumeric (svalue) Then dblsize = bytestomegabytes (cdbl (svalue) svalue = CSTR (dblsize) & "MB" end if listview1.listitems (lindex ). subitems (5) = svaluenext cleanup: Set ologicaldisk = nothingset ologicaldiskset = nothingset owminamespace = nothingexit sub errorhandle R: msgbox "" & err. description goto cleanup end sub private sub command1_click () unload meend sub private function bytestomegabytes (bytes as double) as double dim dblans as double dblans = (Bytes/1024) /1024 bytestomegabytes = format (dblans, "###,##,## 0.00") end function private sub command2_click () dim owminamespace as swbemservicesdim systemset as variantdim system as variantdim objset as Varian Tdim OBJ as Variant set owminamespace = GetObject ("winmgmts:") 'operating system set systemset = owminamespace. instancesof ("win32_operatingsystem") for each system in systemset list1.additem system. caption list1.additem system. manufacturer list1.additem system. buildtype & "" in 'win9x does not seem to be able to retrieve list1.additem system. version list1.additem system. serialnumbernext 'cpuset objset = owminamespace. instancesof ("win32_processo R ") for each OBJ in objset list2.additem obj. caption list2.additem obj. currentclockspeed & "MHz" next end sub private sub command3_click () dim owminamespace as swbemservicesdim objset as variantdim OBJ as variantdim adapter as variant 'memory set owminamespace = GetObject ("winmgmts :") set objset = owminamespace. instancesof ("win32_physicalmemory") dim I as string for each OBJ in objset list3.additem bytest Omegabytes (obj. capacity) & "MB" & "chip" next 'Nic set sink = new swbemsink set adapter = GetObject ("winmgmts:") adapter. instancesofasync sink, "win32_networkadapter" End sub private sub form_load () J = 0end sub private sub sink_onobjectready (byval ob1_bemobject as wbemscripting. iswbemobject, byval objwbemasynccontext as wbemscripting. iswbemnamedvalueset) dim adapter as variant get all the adapter information set Adapter = GetObject ("winmgmts: win32_networkadapterconfiguration =" & J & "") list4.additem adapter. description if isnull (adapter. macaddress) Then list4.additem "No MAC address" list4.additem "" else list4.additem "Mac:" & adapter. macaddress list4.additem "" end if J = J + 1end sub after execution, it appears as follows: Do you feel the power of WMI. (End) Note: WMI has been installed in Windows2000/XP. The WMI for Win9x driver is not supported by Win98 by default.: Http://www.microsoft.com/downloads/details.aspx? Familyid = 98a4c5ba-337b-4e92-8c18-a63847760ea5 & displaylang = en
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service