Registry              from Spatial Solutions Inc.
available through www.spatial-online.com
...query or modify the registry from ArcView

Table of Contents Overview

Registry provides a means for ArcView developers to access the Registry. It comes with a dll which the script assumes is placed in the \bin32 subdirectory under the ArcView installation, most likely c:\Esri\Av_gis30\Arcview\bin32. A sample ArcView script will be loaded into the system scripts when Registry is installed and help will be available through Help > Registry when a script is open.

WARNING !! Modifying values in the Registry can be dangerous. Many programs assume the values to be appropriately set and will not run if they are modified. Please use with caution.

Return to Table of Contents

Installation Instructions

Registry, amongst other ArcView extensions, can be downloaded and installed for a free trial from www.spatial-online.com. The file that is downloaded is called Registry.exe. Double click on the file, and an Install Wizard will guide you through the installation.

After installation, the extension will be available through the usual ArcView extension directory. To load the extension,

After the extension is loaded, when the Script Menu is visible, there will be an Registry option under Help. It will bring up this help screen. It utilizes EvokeBrowser to evoke the standard browser with Registry.htm.

Return to Table of Contents

Use in ArcView

The Registry dll provides 4 functions for accessing the registry:

Each function returns an error code.
  • 0 - Success.
  • -1 - Could not find the MasterKey.
  • -2 - Could not find the SubKey.
  • -3 - Could not find a data value with name NameOfData, or the size of the data buffer was insufficient.
The parameters are:
  • MasterKey: A string defining the Master Key. It can be any one of:
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
    • HKEY_CURRENT_CONFIG
  • SubKey: A string defining the Key you wish to access. It can be anything in the registry. For example, the Registry dll stores information in the key SOFTWARE\SpatialOnline\Registry.
  • NameOfData: A string defining the name of the value you are interested in. For example, the Registry dll stores data called Path.
  • TypeOfData: Most data in the registry is string data (REG_SZ) or a numeric value (REG_DWORD). However, data can be stored in any of the following formats:
    REG_BINARYBinary data in any form.
    REG_DWORDA 32-bit number.
    REG_DWORD_LITTLE_ENDIANA 32-bit number in little-endian format. This is equivalent to REG_DWORD.
    In little-endian format, a multi-byte value is stored in memory from the lowest byte (the "little end") to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format.
    Windows NT, Windows 95, and Windows 98 are designed to run on little-endian computer architectures. A user may connect to computers that have big-endian architectures, such as some UNIX systems.
    REG_DWORD_BIG_ENDIANA 32-bit number in big-endian format.
    In big-endian format, a multi-byte value is stored in memory from the highest byte (the "big end") to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format.
    REG_EXPAND_SZA null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It will be a Unicode or ANSI string depending on whether you use the Unicode or ANSI functions.
    REG_LINKA Unicode symbolic link.
    REG_MULTI_SZAn array of null-terminated strings, terminated by two null characters.
    REG_NONENo defined value type.
    REG_RESOURCE_LISTA device-driver resource list.
    REG_SZA null-terminated string. It will be a Unicode or ANSI string depending on whether you use the Unicode or ANSI functions.
    If the data type cannot be found REG_SZ is assumed.
  • LengthOfData: An integer containing the length of data buffer area. Note that this must be set prior to a GetKey call as well as a PutKey call as the program will not return more characters than this. If the buffer is not long enough, a -3 error will be returned.
  • Data: A buffer either specifying the data to write, or to hold the data to read. A string buffer can be defined by buffer = String.MakeBuffer(256).

To evoke any of these functions, you must define the dll and the function. The following Avenue code achieves this:

dllName = system.GetEnvVar( "AVHOME")+"\Bin32\" + "Registry.dll"
dllReg = DLL.Make(dllName.AsFileName)
if (dllReg = nil) then 
  msgbox.error( "Could not load Registry.dll","Registry") 
  return 0
end 
  
GetKey = DLLProc.Make(dllReg,"GetKey",#DLLPROC_TYPE_INT32,{#DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_PINT32, #DLLPROC_TYPE_STR})
if (GetKey = nil) then
  msgbox.error( "Could not make GetKey", "Registry")
  return 0
end 

PutKey = DLLProc.Make(dllReg,"PutKey",#DLLPROC_TYPE_INT32,{#DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_INT32, #DLLPROC_TYPE_STR})
if (PutKey = nil) then
  msgbox.error( "Could not make PutKey", "Registry")
  return 0
end 

DeleteValue = DLLProc.Make(dllReg,"DeleteValue",#DLLPROC_TYPE_INT32,{#DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR})
if (DeleteValue = nil) then
  msgbox.error( "Could not make DeleteValue", "Registry")
  return 0
end 

DeleteKey = DLLProc.Make(dllReg,"DeleteKey",#DLLPROC_TYPE_INT32,{#DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR})
if (DeleteKey = nil) then
  msgbox.error( "Could not make DeleteKey", "Registry")
  return 0
end 

The functions are then evoked using the DLLProc Call. Examples of calls are:
strData = String.MakeBuffer(1000)
nData = strData.Count
strType = String.MakeBuffer(24)
nReturn = GetKey.Call({"HKEY_LOCAL_MACHINE", "SOFTWARE\SpatialOnline\Registry", "Path", strType, nData, strData})
if (nReturn = 0) then
  msgBox.info("The path of the Registry help is " + strData, "Registry")
else
  msgBox.info("The path could not be retreived.  It returned error code " + nReturn.AsNumber, "Registry")
end

strData = "New Data"
nReturn = PutKey.Call({"HKEY_LOCAL_MACHINE", "SOFTWARE\SpatialOnline\Registry\NewKey", "NewData", "REG_SZ", strData.Count, strData})
if (nReturn = 0) then
  msgBox.info("A new key and new value are added","Registry")
else
  msgBox.info("The new value could not be added.  It returned error code " + nReturn.AsNumber, "Registry")
end

nReturn = DeleteValue.Call({"HKEY_LOCAL_MACHINE", "SOFTWARE\SpatialOnline\Registry\NewKey", "NewData"})
if (nReturn = 0) then
  msgBox.info("The new value is deleted","Registry")
else
  msgBox.info("The new value could not be deleted.  It returned error code " + nReturn.AsNumber, "Registry")
end

nReturn = DeleteKey.Call({"HKEY_LOCAL_MACHINE", "SOFTWARE\SpatialOnline\Registry\NewKey", "NewData"})
if (nReturn = 0) then
  msgBox.info("The new key is deleted","Registry")
else
  msgBox.info("The new key could not be deleted.  It returned error code " + nReturn.AsNumber, "Registry")
end
There is also a sample script included with the extension. To include the code within your script, when the script is active, click Script > Load System Script. Scroll down to Registry.Sample and highlight it. Click OK.

Return to Table of Contents

Frequently Asked Questions

  • Why is it dangerous to modify the Registry?
    • Many Windows processes utilize the registry to store a lot of information critical to the efficient running of your computer. Modifying these values could render your computer inoperable.

  • When is the registry usually used?
    • The registry can be used to store information between activities, even if the computer is shut down. For instance, if the user has the ability to install a program in a folder of their choice, it is useful to store the name of that folder in the registry so that it can be found by other programs later.

Return to Table of Contents

Other SSI Products

Spatial Solutions Inc. offers four products for the cleaning and building of polygons.

  • SSIArcPolyClean cleans line work. It computes intersections, removes overshoots, undershoots and small polygons such as caused by snap backs, and produces a shape file containing the clean lines as well as a shape file containing lines that are not part of polygon boundaries and a point shape file noting where the lines are dangling. Click here to download a free evaluation of this product.
  • SSIArcPolyBuild produces polygon shape files from line shape files, describing the boundaries, and point shape files, linked to the attributes of the polygons. It correctly deals with any level of "donuts", that is a polygon, or group of polygons, that are completely contained within a single polygon. These are also referred to as "island" polygons. They can be nested to any level, such as a lake on an island within a larger lake. Click here to download a free evaluation of this product.
  • SSIArcPoly, this product, cleans and builds polygons in one step. Click here to download a free evaluation of this product or purchase the product online.
  • SSIArcWeed removes redundant points from lines while retaining the essential shape. It is particularly useful when data has been stream digitized or originated from a map at a lower scale. Click here to download a free evaluation of this product.

This help is provided from within ArcView by the assistance of a free utility called EvokeBrowser. This product enables one to evoke the default browser from within Avenue code. Click here to download the free utility EvokeBrowser.

While modifying the registry is dangerous, it is also sometimes necessary. SSI provides a free utility to access the registry from within Avenue. Click here to download the free utility Registry.

Return to Table of Contents

About Registry

The software comes "as is". Neither Spatial Solutions Inc. or www.spatial-online.com make any warranty, representation, promise or guarantee of any kind, either expressed or implied, statutory or otherwise, including, but not limited to the implied warranties of quality, performance, non-infringement, merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the software is with the user. We do not warrant that the functions contained in the software will meet your requirements or that the operation of the software will be uninterrupted or error free.

Return to Table of Contents