Domino Code Fragment

Code Name*
Working with the Windows API
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.219.22.169
Description*
In developing advanced applications, it's often important to access functions of the operating system. This is an example of calls to the registry.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
In particular, properties and values such as the location of certain files or the programs associated with data types are useful in integrating 1-2-3 with other programs that share the Windows environment.


From 1-2-3's standpoint, the Windows Applications Programming Interface (API) can be considered to be the C function calls that are available in the dynamic link libraries (DLLs) that come with Windows, although LotusScript will work with other DLLs as well.
1-2-3 Release 5 used a macro command named {Register} to make a DLL function available as an @function. The {Register} command is no longer supported. Instead, the Declare statement permits routines in DLLs to be made available as Subs and Functions in LotusScript.
When using Declare, you must specify the name of the routine (including an alias), the library in which it is stored, any arguments the routine takes, and tthe type of the return value. In specifying the name of the routine, it's important to be aware that LotusScript converts all names to uppercase. The case of the alias, however, is preserved, so unless the name of the routine is already uppercase, the alias is critically important.
The examples below declare functions relating to the registry, including opening a key, querying its value, and closing the key.


Declare Function RegOpenKeyExA Lib "advapi32" Alias "RegOpenKeyExA"_
(Byval HKEY As Long,Byval lpszSubKey As String,Byval dwreserved As Integer,Byval samDesired As Long, keyresult As Long)_
As Long


Declare Function RegQueryValueExA Lib "advapi32" Alias "RegQueryValueExA"_
(Byval HKEY As Long,Byval lpszValueName As String,Byval dwreserved As Integer,lpdwtype As Long,Byval lpData As String,readbytes As Long)_
As Long


Declare Function RegCloseKey Lib "advapi32" Alias "RegCloseKey" (Byval HKEY As Long) As Long