Created By  inflectra.adam Tuesday, March 29, 2016
Sometimes when testing local/desktop applications you need to access the Windows registry to verify that keys exist or that keys have specific values. For example you may be testing that a DLL was successfully registered. This article provides information on the 'UsingRegistry' sample that comes with Rapise.
The following sample 'UsingRegistry' is shipped as part of the default installation, so the first thing to do is:
  • Go to the Rapise Start Page
  • Click on Fetch Samples to make sure that you have all the latest samples
  • Browse the samples to see the UsingRegistry sample.

The sample demonstrates the usage of the Windows Registry:

  • The sample gets the registry values to determine the OS type (Win7/8/10/2008/2012, etc)
  • The sample also gets the OS version and the Owner
  • The sample uses the standard object WScript.Shell and its method RegRead to access the Registry

   //Creates an WScript.Shell object.
var shl = new ActiveXObject("WScript.Shell");

    var osType = GetOsType();
Tester.Assert("The machins OS type", true, osType);

    var osVersion = GetOsVersion();
    Tester.Assert("The service pack version", true, osVersion);

    var osOwner = GetOsOwner();
Tester.Assert("The registered owner of OS", true, osOwner);

     * Reads OS type from registry.
     * @returns OS type.

    function GetOsType()
return shl.RegRead ("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName");

     * Reads OS service pack version from registry.
     * @returns Service pack version.
function GetOsVersion()
return shl.RegRead ("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\CSDVersion"); 
return "No service pack";

     *Reads OS registered owner from registry.
     *@returns OS registered owner.
function GetOsOwner()
return shl.RegRead ("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\RegisteredOwner");

Further Reading

For more information on the Windows API / Scripting Host methods being used, please refer to:

Article Info
  • Last Updated: 3/29/2016
  • Article ID: KB203
  • Views: 1765