Recently I needed to read some information from the registry. Before seaching in older source code, I was sure I would find it in the forum. However, I did not - so here it is 😄
program test_win32api
IMPLICIT NONE
include 'win32api.ins'
INTEGER,PARAMETER::HKEY_CLASSES_ROOT =Z'80000000'
INTEGER,PARAMETER::HKEY_CURRENT_USER =Z'80000001'
INTEGER,PARAMETER::HKEY_LOCAL_MACHINE=Z'80000002'
INTEGER,PARAMETER::HKEY_USERS =Z'80000003'
INTEGER,PARAMETER::BUFSIZE=256
INTEGER hKey,res,cbValue
CHARACTER(LEN=BUFSIZE) InstallLocation
CHARACTER(LEN=BUFSIZE), &
PARAMETER::RegPath='Software\\Silverfrost\\Silverfrost FTN95\\6.00'
cbValue = BUFSIZE
res = RegOpenKey(HKEY_LOCAL_MACHINE,TRIM(RegPath),hKey)
IF(res /= 0) STOP 'ERROR:Cannot open registry key'
res = RegQueryValueEx(hKey,'InstallLocation',CORE4(0),CORE4(0),InstallLocation,cbValue)
IF(res /= 0)THEN
PRINT*,'ERROR:Cannot read key'
ELSE
PRINT*,InstallLocation(1:LEN_TRIM(InstallLocation))
ENDIF
res = RegCloseKey(hKey)
end test_win32api