MS Info in Applications
By Richard A. Schummer
Originally Published in the September 1997 issue of FoxTalk
Copyrighted 1997 - Richard A. Schummer
Microsoft has included a very powerful applet called Microsoft System Information with each of the Microsoft Office and Visual Tools. This applet, also known as MS Info is used to get detailed information about a PC. MS Info is typically accessed from any About window in Visual FoxPro, Word, Excel, PowerPoint, or Access via the System Info CommandButton.
Custom applications that have the same look and feel as other applications have proven to be easier to train users on and reduce support requests. Adding the System Info CommandButton to a custom application About window not only provides the same look and feel, but also provides the support staff the capability of “checking under the hood” when something unexplainable is happening with the application. This applet allows support personnel to determine the configuration of an end user’s computer. Information available is as basic as CPU platform, amount of memory, fonts, graphic display features and printer drivers loaded. It also provides in-depth detail about the DLLs that are loaded and their versions. The information is specific to the computer that it is run on. One can easily check to see if the system meets minimum configuration requirements and check out what else is loaded to see if conflicts exist or an old version of a DLL or printer driver is loaded.
The First Cut
The first approach taken seemed simple at first. Drop a CommandButton on a form, and modify the Click() method to execute the MSInfo32 executable.
RUN /n1 “C:\Program Files\Common Files\Microsoft Shared\MSINFO\msinfo32.exe”
This worked fine on the development machine and several other machines that followed the standard install for MS Office. Then there was the exception. This was not a big deal since there was a check to see if the executable existed before it is run, but the user is a bit confused since their teammate in the next cubicle can see all this information. A classic case of information envy and great material for Scott Adam’s next Dilbert book.
The Final Solution
So what is a developer to do to make this generic? It just so happens that there is an entry in the Window’s Registry that reveals the exact location of the MS Info applet. The entry is:
A new solution was to build a class that contains a CommandButton and a Registry reader class. A Registry Reader class performs a number of functions like opening up the Window’s Registry, searches for a key, opens the key, and reads the value. There is a program called Registry.prg that is included with the Visual FoxPro Solutions that accomplishes the needed action. This example code works great and is fairly easy to understand. Another Registry Reader classes is the CSystemSettings/CRegistry classes that are included in Visual Codebook 3.0 written by Yair Alan Griver. Both approaches allow easy access to the Window’s Registry and remove some of the complications of getting the needed values.
The Registry entry sub-key for the location of MS Info is “Path”. This was a little confusing at first since one might just expect the directory path, but the executable name is also part of the value.
First thing to do is read the registry. Once the location is determined place the location path of the executable into a custom property for the class. If the entry is not found in the Registry or the executable is not where it is suppose to be, the System Info CommandButton gets disabled. This code is from the ctrMSInfo.Init() method which is included in the sampled code on the FoxTalk Website.
#DEFINE ccREG_KEY "SOFTWARE\Microsoft\Shared Tools\MSInfo"
#DEFINE HKEY_LOCAL_MACHINE -2147483646 && BITSET(0,31)+2
LOCAL lcMSInfo && Path to the executable
lcMSInfo = ""
* Get the registry retry for the path to the
* Microsoft Shared tool known as MSInfo.
lcMSInfo = THIS.ctrRegistry.Get(ccREG_KEY, ;
THIS.cMSInfoExeFile = lcMSInfo
* Disable the commandbutton if registry entry
* is not found or executeable file not available.
IF EMPTY(.cMSInfoExeFile) OR ;
.cmdMSInfo.Enabled = .F.
The code in the cmdMSInfo.Click() method is:
* Define a local variable used in macro expansion
* since the property cannot be macro expanded
lcRunProgram = THIS.PARENT.cMSInfoExeFile
* Run MSInfo in Normal/Active Mode
RUN /n1 &lcRunProgram
It is important to note that VFP developers cannot distribute the MS Info executable as part of their custom applications. This is clearly stated in the documentation included with VFP. There is a complete list of files that cannot be distributed in the License.txt file in the main VFP directory. However, there is no harm including this functionality into your apps if the file is available on the user’s PC.
There is nothing better than releasing bug free applications that completely meet a customers requirements and expectations. These cases are very rare. The next best thing is to lower training and support issues and making the life of the customer and the technical support staff easy when anomalies are being tracked down. Tools like MS Info go a long way in helping out and adding features like this can give your applications a consistent look and feel which gives it a more polished look.
This site is designed to be viewed in 800x600 video resolution or higher, but it should work fairly well at any resolution and with any of the major browsers (all free!). Optimized for MS Internet Explorer, Firefox, and Opera (mostly works with Mozilla and Netscape Navigator).
Copyrighted 1998-2005 Richard A. Schummer