LabWindows/CVI User Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get informations on the system through WMI in CVI (Windows Management Instrumentation)

Overview

This document describes how to use Win32 APIs to query system informations through WMI (Windows Management Instrumentation), a powerful tool that is installed on modern operating systems of the Windows family (starting from Windows ME on).

The amount of informations available through WMI is huge: this sample program demontrates how to approach this instrument by displaying some data about the operating system and the system enclosure. Make reference to microsoft documentation and to the interface to the Win32 API that comes with CVI for additional information.

 

 

Description

While discouraging direct access to the Windows registry, Microsoft has added a set of functions to retrieve every type of informations you may need to know about the system your application is running on. WMI is a powerful instrument to get these data, but its access through CVI is not a trivial task.

 

This project is mainly taken tfrom example code that can be found within the Interface to Win32API that can be installed with CVI Full Development System, simply ported and adapted to CVI environment. Additional code samples can be found on Microsoft website.

 

Examples of data available through WMI are information on the operating system and the system enclosure, some of which are retrieved in this example; information on disks, mouse, files, networking, services and so on are available as well: the complete list is here on MSDN; the same documentation could be installed on system by older versions of CVI.

 

 

Steps to Implement or Execute Code

The sample program is ready to go. It uses only standard functions included in the CVI installation. No additional tools are required to execute it.

The application is based on the Win32 Interface to the system APIs: it is well possible that it requires the Full Develpment System release of CVI to be executed. I have no Base package install available to test it against so I'm not sure, but I suppose WMI functions are not included in the base system.

 

Here a reproduction of the example window:

Screenshot 2020-02-13 13.17.20.png

 

Requirements

Software

CVI Full Development System release 2015 or later with support for Win32 API installed.

No additional tools needed.

 

Hardware

No hardware is needed to run this example.

 

 

UPDATE

Added option to retrieve information on network adapters

(2017) Added options to get power supply information (useful when running on laptops) and disk info

(2019) Updated to CVI 2015. Reorganized the UI and added option to get serial ports data



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Comments
IDASYAN
Member
Member
on

Hello RobertoBozzolo, 

I have a question related to the project. 

Is it possible to also get the System Type(64/32 bit OS) information? 

Thx. 

IEE_newsoft
Member
Member
on

Hi Roberto,


really a great job, this one! I already implemented derivates of this into my project (indication/separation of com0com ports).
It also helped me to identify some processes and the commandlines they've been called with.


Since MS has deprecated the wmic command, we're all forced to migrate to the unfairly much more complex wmi mechanisms.

I'm now struggling on how to terminate a process on a local PC using wmi.

Using wmic, it was pretty simple, it was a one-line shell command.

Using wmi, I found some examples in C++/C# or VB.net, but none of them I was able to migrate to Ansi C

Do you have something in your big portfolio that could help me?


Thanx and Regards

Manfred

Contributors