Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 19443, Let us try WMI (samples)

by Vladimir Afanasyev Email: Anonymous

WMI very powerful Windows Management technology. It available for Windows 2000/XP (for Win95/98/NT4 you need download WMICore from MSDNLibrary site).
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For C++Builder, Version 5.0  to 6.0 2212 downloads
Copyright: Open Source or other

Size: 64,026 bytes
Updated on Fri, 25 Jul 2003 03:40:57 GMT
Originally uploaded on Wed, 08 Jan 2003 02:40:39 GMT
SHA1 Hash: 4F09D46FDF327B0BED2D2CA0CB97D8AB4043D52D
MD5 Hash: 89D12D61696ECBED1D5B95706D6E84A3

    Explore the files in this upload

I create and put here some samples of using WMI in the BCB application. All samples was tested for Win2000. This samples can be very useful for novices in WMI (and not only for novices). To understand this powerful technology I suggest to find some article on MSDN(MSJ) Magazine site and for deeply understanding download WMI SDK from MSDN Library site.

Note for BCB6 developers: Before building projects set Registers variables in None in page Advanced Compiler (Project options). This way the problem BCB5-BCB6 incompatibility (type Variant) is solved. I grateful to Michael Joss and Giuliano Cardinali for their really big help in finding solution.
Some words about samples:
First three samples demonstrate connections to WMI (first - early binding, second and third - later binding).
1) Enumerating Com ports and obtaing characteristics of port. (early binding to WMI using IWbemXXX interfaces). It is not always that com ports has numbers com1, com2 etc, for some OS (2000/XP) it is possible to change it(for example, com11, com122 etc.). Sample demonstrates enumeration using WMI possibility.
2) Obtain BIOS information (later binding using Variant's CreateObject).
3) Enumerating services, Start service, Stop service etc (later binding using Monikers). It is interesting for me to explore relates between monikers and WMI. I did not find information in the MSDN Library (for C++), so now you can see my solution.
4) Process spier. You can see all active processes and changes (start new process, end existing process) in the window. Sample demonstrates how to obtain notifications from WMI.
09.01.2003 For sample 4. I add critical section for adding and
deleting data to and fro listbox. I fixed that some "very very system processes" may have not path.
17.01.2003 I did small changes in the previous samples and add three new.
5) Prevent application from running. Obtain notifications about creating new process and delete instance of selected application.
Two next samples for access two remote PC, so you need to be Network Administrator to run its.
6) Obtaining information about remote PC - user name, domain, number of processors, etc.
7) Obtaining information about remote PC shares - names, path, etc.
8)I add sample for network adapters (question from comments to download).
Important note: For WMI is important to change COM thread model multithreaded instead apartmen. See carefully project cpp file to understand how to do it.
I have done some changes because exist some Variant type
incompatibility BCB5 and BCB6.

   Latest Comments  View All Add New

Move mouse over comment to see the full text
Reply  Posted by Vladimir Afanasyev on Feb 11 2003
re: Let us try WMI (samples)

Server Response from: ETNACDC03