I've written a library for the Windows Registry. The code works for 64 bit. I have not considered 32 bit at all. It may or may not work for that architecture.
External libraries used:
winreg.h
shlwapi.dll
shell32.dll
shellapi.h
List of
FUNCTIONS/SUBS contained in library:
SelfElevate (This function is used automatically by the library when certain registry keys are accessed.)
CreateRegistryKey (Creates a registry key)
DeleteRegistryKey (
WARNING: Recursively deletes a key and its subkeys.)
WriteREG_DWORD (Writes an
UNSIGNED LONG value to a key)
WriteREG_QWORD (Writes an
UNSIGNED INTEGER64 value to a key)
WriteREG_SZ (Writes a
STRING value to a key)
ReadREG_DWORD (Reads an
UNSIGNED LONG value from a key)
ReadREG_QWORD (Reads an
UNSIGNED INTEGER64 value from a key)
ReadREG_SZ (Reads a
STRING value from a key)
IsInstalled (Iterates through the x86 registry to determine if a program is installed. Calls
IsInstalled64 if the program is not found.)
IsInstalled64 (Iterates through the x64 registry to determine if a program is installed.
Call IsInstalled instead of calling this function directly.)
CheckVersion (Iterates through the x86 registry to locate the specified program and return the version string. Calls
CheckVersion64 if the program is not found.)
CheckVersion64 (Iterates through the x64 registry to locate the specified program and return the version string.
Call CheckVersion instead of calling this function directly.)
GetUninstallString (Iterates through the x86 registry to locate the specified program and return the uninstall string. Calls
GetUninstallString64 if the program is not found.)
GetUninstallString64 (Iterates through the x64 registry to locate the specified program and return the uninstall string.
Call GetUninstallString instead of calling this function directly.)
EnumInstalledPrograms (Iterates through the x86 registry to enumerate all installed programs. Calls
EnumInstalledPrograms64 so as to completely list all programs.)
EnumInstalledPrograms64 (Iterates through the x64 registry to enumerate all installed programs.
Call EnumInstalledPrograms instead of calling this function directly.)
The library:
Sample code:
'$Include:'WinReg.BI'
'The following code demonstrates creating a new registry key to use a custom URL protocol of "qb64:" to launch qb64.exe
status = CreateRegistryKey(HKEY_CLASSES_ROOT, "qb64")
Print "Failed to create key"
status = WriteREG_SZ(HKEY_CLASSES_ROOT, "qb64", "", "URL:QB64 Protocol")
Print "Failed to insert value into registry key"
status = WriteREG_SZ(HKEY_CLASSES_ROOT, "qb64", "URL Protocol", "")
Print "Failed to insert value into registry key"
status = WriteREG_SZ(HKEY_CLASSES_ROOT, "qb64", "DefaultIcon", "qb64.exe,1")
Print "Failed to insert value into registy key"
status = CreateRegistryKey(HKEY_CLASSES_ROOT, "qb64\shell\open\command")
Print "Failed to create key"
status
= WriteREG_SZ
(HKEY_CLASSES_ROOT
, "qb64\shell\open\command", "", Chr$(34) + _CWD$ + "\qb64.exe" + Chr$(34) + " " + Chr$(34) + "%1" + Chr$(34)) Print "Failed to insert value into registry key"
status = ReadREG_SZ(HKEY_CLASSES_ROOT, "qb64\shell\open\command", "", cmd)
Print "Failed to read value"
'Delete the key we just made
Print DeleteRegistryKey
(HKEY_CLASSES_ROOT
, "qb64") '$Include:'WinReg.BM'
'$Include:'WinReg.BI'
'The following code demonstrates checking if PowerShell 7 is installed and, if so, displays the version string and the uninstall string
If IsInstalled
("powershell 7-x64") Then Print CheckVersion
("powershell 7-x64") Print GetUninstallString
("powershell 7-x64")
EnumInstalledPrograms
'$Include:'WinReg.BM'