Please note javascript is required for full website functionality.

Blog

A to Z of Excel Functions: The REGISTER Function

23 September 2024

Welcome back to our regular A to Z of Excel Functions blog.  Today we look at the REGISTER function.

 

The REGISTER function

Ah, the mysterious REGISTER function.  Microsoft has one of its longest Help pages on this wonderful beast, alas little of it informative.  This function returns the registry ID for a specific DLL (Dynamic Linked Library), which is a shared library in the Microsoft Windows or OS/2 operating system.  A DLL can contain executable code, data and resources in various combinations, and are designed to allow other programs to use them.

Amongst other utilities, this information may be used for registry modification (the registry is a centralised, hierarchical database that manages resources and stores configuration settings typically for applications on the Windows operating system).  Incorrectly editing said registry may severely damage your operating system, requiring you to reinstall it.  That’s not a good idea, especially as Microsoft will not guarantee that problems resulting from editing the registry incorrectly may even be resolved. Before editing the registry, back up any valuable data.  

In summary, if you’re not sure what you’re doing, stop reading now!

The REGISTER function cannot be used in Excel for the web at all, or apparently on worksheets for other types of Excel.  Associated with the CALL function, and similar to the C API XLM function xlfRegister, it appears to be used on Excel XLM macro sheets (this fact is unverified).

The syntax is not straightforward.  The arguments and return values differ depending upon your operating environment, but includes a type_text argument.  This argument specifies the data type of the return value and the data types of all arguments to the DLL function or code resource.  The first character of type_text specifies the data type of the return value.  The remaining characters indicate the data types of all the arguments.  For example, a DLL function that returns a floating-point number and takes an integer and a floating-point number as arguments would require "BIB" for the type_text argument.

The following table contains a complete list of the data type codes that Microsoft Excel recognises, a description of each data type, how the argument or return value is passed, and a typical declaration for the data type in the C programming language.  Fun.

It should be noted that:

  • the C language declarations are based on the assumption that your compiler defaults to 8-byte doubles, 2-byte short integers and 4-byte long integers
  • in the Microsoft Windows programming environment, all pointers are far pointers.  For example, you must declare the D data type code as unsigned char far * in Microsoft Windows
  • all functions in DLLs and code resources are called using the Pascal calling convention.  Most C compilers allow you to use the Pascal calling convention by adding the Pascal keyword to the function declaration, as shown in the following example: pascal void main (rows,columns,a)
  •  if a function uses a pass-by-reference data type for its return value, you can pass a null pointer as the return value.  Microsoft Excel will interpret the null pointer as the #NUM! error value.

Good luck understanding any of this.

 

We’ll continue our A to Z of Excel Functions soon.  Keep checking back – there’s a new blog post every business day.

A full page of the function articles can be found here

Newsletter