' ########################################################################################
' Microsoft Windows
' File: WinReg.inc
' Contents: This module contains the function prototypes and constant, type and structure
' definitions for the Windows 32-Bit Registry API.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_WinReg_PBI)
#DEFINE PBX_WinReg_PBI
%EQUATE `WINREG_INC = 1
#INCLUDE ONCE "Legacy/System/WTypes.inc"
#INCLUDE ONCE "Core/Windows.inc"
'#ifndef WINVER
'#define WINVER 0x0500 // version 5.0
'#endif /* !WINVER */
'//
'// RRF - Registry Routine Flags (for RegGetValue)
'//
%EQUATE `RRF_RT_REG_NONE = &H00000001 ' // restrict type to REG_NONE (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_REG_SZ = &H00000002 ' // restrict type to REG_SZ (other data types will not return ERROR_SUCCESS) (automatically converts REG_EXPAND_SZ to REG_SZ unless RRF_NOEXPAND is specified)
%EQUATE `RRF_RT_REG_EXPAND_SZ = &H00000004 ' // restrict type to REG_EXPAND_SZ (other data types will not return ERROR_SUCCESS) (must specify RRF_NOEXPAND or RegGetValue will fail with ERROR_INVALID_PARAMETER)
%EQUATE `RRF_RT_REG_BINARY = &H00000008 ' // restrict type to REG_BINARY (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_REG_DWORD = &H00000010 ' // restrict type to REG_DWORD (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_REG_MULTI_SZ = &H00000020 ' // restrict type to REG_MULTI_SZ (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_REG_QWORD = &H00000040 ' // restrict type to REG_QWORD (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_DWORD = %RRF_RT_REG_BINARY OR %RRF_RT_REG_DWORD ' // restrict type to *32-bit* RRF_RT_REG_BINARY or RRF_RT_REG_DWORD (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_QWORD = %RRF_RT_REG_BINARY OR %RRF_RT_REG_QWORD ' // restrict type to *64-bit* RRF_RT_REG_BINARY or RRF_RT_REG_DWORD (other data types will not return ERROR_SUCCESS)
%EQUATE `RRF_RT_ANY = &H0000ffff ' // no type restriction
%EQUATE `RRF_NOEXPAND = &H10000000 ' // do not automatically expand environment strings if value is of type REG_EXPAND_SZ
%EQUATE `RRF_ZEROONFAILURE = &H20000000 ' // if pvData is not NULL, set content to all zeros on failure
'//
'// Flags for RegLoadAppKey
'//
%EQUATE `REG_PROCESS_APPKEY = &H00000001
'//
'// Flags for RegLoadMUIString
'//
%EQUATE `REG_MUI_STRING_TRUNCATE = &H00000001
'//
'// Requested Key access mask type.
'//
'typedef ACCESS_MASK REGSAM;
MACRO REGSAM = ACCESS_MASK
'//
'// Reserved Key Handles.
'//
%EQUATE `HKEY_CLASSES_ROOT = &H80000000 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000000) )
%EQUATE `HKEY_CURRENT_USER = &H80000001 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000001) )
%EQUATE `HKEY_LOCAL_MACHINE = &H80000002 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000002) )
%EQUATE `HKEY_USERS = &H80000003 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000003) )
%EQUATE `HKEY_PERFORMANCE_DATA = &H80000004 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000004) )
%EQUATE `HKEY_PERFORMANCE_TEXT = &H80000050 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000050) )
%EQUATE `HKEY_PERFORMANCE_NLSTEXT = &H80000060 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000060) )
'#if(WINVER >= 0x0400)
%EQUATE `HKEY_CURRENT_CONFIG = &H80000005 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000005) )
%EQUATE `HKEY_DYN_DATA = &H80000006 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000006) )
%EQUATE `HKEY_DYNAMIC_DATA = %HKEY_DYN_DATA ' Not in Windows 7 SDK
%EQUATE `HKEY_CURRENT_USER_LOCAL_SETTINGS = &H80000007 ' (( HKEY ) (ULONG_PTR)((LONG)0x80000007) )
' *** For compatibility with PowerBASIC's win32api.inc file ***
%EQUATE `HKCR = %HKEY_CLASSES_ROOT
%EQUATE `HKCU = %HKEY_CURRENT_USER
%EQUATE `HKLM = %HKEY_LOCAL_MACHINE
%EQUATE `HKU = %HKEY_USERS
%EQUATE `HKPD = %HKEY_PERFORMANCE_DATA
%EQUATE `HKCC = %HKEY_CURRENT_CONFIG
%EQUATE `HKDD = %HKEY_DYN_DATA
'//
'// RegConnectRegistryEx supported flags
'//
'#define REG_SECURE_CONNECTION 1
%EQUATE `REG_SECURE_CONNECTION = 1
'/*NOINC*/
'#ifndef _PROVIDER_STRUCTS_DEFINED
'#define _PROVIDER_STRUCTS_DEFINED
%EQUATE `PROVIDER_KEEPS_VALUE_LENGTH = &H1
' // Size = 12 bytes
TYPE val_context DWORD
 valuelen AS LONG ' int // the total length of this value
 value_context AS DWORD ' LPVOID // provider's context
 val_buff_ptr AS DWORD ' LPVOID // where in the ouput buffer the value is.
END TYPE
' // Size = 16 bytes
TYPE PVALUEA DWORD ' // Provider supplied value/context.
 pv_valuename AS ASCIIZ PTR ' LPSTR // The value name pointer
 pv_valuelen AS LONG ' int
 pv_value_context AS DWORD
 pv_type AS DWORD
END TYPE
' // Size = 16 bytes
TYPE PVALUEW DWORD ' // Provider supplied value/context.
 pv_valuename AS WSTRINGZ PTR ' LPWSTR // The value name pointer
 pv_valuelen AS LONG ' int
 pv_value_context AS DWORD
 pv_type AS DWORD
END TYPE
' // PVALUE can't be used because it conflicts with several existing
' // pValue variables used as parameters in functions.
'typedef
'DWORD __cdecl
'QUERYHANDLER (LPVOID keycontext, PVALCONTEXT val_list, DWORD num_vals,
' LPVOID outputbuffer, DWORD FAR *total_outlen, DWORD input_blen);
' // Size = 24 bytes
TYPE REG_PROVIDER DWORD
 pi_R0_1val AS DWORD
 pi_R0_allvals AS DWORD
 pi_R3_1val AS DWORD
 pi_R3_allvals AS DWORD
 pi_flags AS DWORD ' DWORD // capability flags (none defined yet).
 pi_key_context AS DWORD
END TYPE
' // Size = 16 bytes
TYPE VALENTA DWORD
 ve_valuename AS ASCIIZ PTR
 ve_valuelen AS DWORD
 ve_valueptr AS DWORD ' DWORD_PTR
 ve_type AS DWORD
END TYPE
' // Size = 16 bytes
TYPE VALENTW DWORD
 ve_valuename AS WSTRINGZ PTR
 ve_valuelen AS DWORD
 ve_valueptr AS DWORD ' DWORD_PTR
 ve_type AS DWORD
END TYPE
MACRO VALENT = VALENTA
'#endif // not(_PROVIDER_STRUCTS_DEFINED)
'/*INC*/
'#endif /* WINVER >= 0x0400 */
'//
'// Default values for parameters that do not exist in the Win 3.1
'// compatible APIs.
'//
'#define WIN31_CLASS NULL
'//
'// API Prototypes.
'//
DECLARE FUNCTION RegCloseKey LIB "advapi32.dll" ALIAS "RegCloseKey" ( BYVAL hKey AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegOverridePredefKey LIB "advapi32.dll" ALIAS "RegOverridePredefKey" ( BYVAL hKey AS QUAD , OPTIONAL BYVAL hNewHKey AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegOpenUserClassesRoot LIB "advapi32.dll" ALIAS "RegOpenUserClassesRoot" ( BYVAL hToken AS QUAD , BYVAL dwOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegOpenCurrentUser LIB "advapi32.dll" ALIAS "RegOpenCurrentUser" ( BYVAL samDesired AS REGSAM , BYREF phkResult AS QUAD ) AS LONG
DECLARE FUNCTION RegDisablePredefinedCache LIB "advapi32.dll" ALIAS "RegDisablePredefinedCache" ( ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDisablePredefinedCacheEx LIB "advapi32.dll" ALIAS "RegDisablePredefinedCacheEx" ( ) AS LONG ' LSTATUS
DECLARE FUNCTION RegConnectRegistryA LIB "advapi32.dll" ALIAS "RegConnectRegistryA" ( BYREF lpMachineName AS ASCIIZ , BYVAL hKey AS QUAD , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegConnectRegistryW LIB "advapi32.dll" ALIAS "RegConnectRegistryW" ( BYREF lpMachineName AS WSTRINGZ , BYVAL hKey AS QUAD , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegConnectRegistry = RegConnectRegistryW
#ELSE
 MACRO RegConnectRegistry = RegConnectRegistryA
#ENDIF
DECLARE FUNCTION RegConnectRegistryExA LIB "advapi32.dll" ALIAS "RegConnectRegistryExA" ( BYREF lpMachineName AS ASCIIZ , BYVAL hKey AS QUAD , BYVAL Flags AS QUAD , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegConnectRegistryExW LIB "advapi32.dll" ALIAS "RegConnectRegistryExW" ( BYREF lpMachineName AS WSTRINGZ , BYVAL hKey AS QUAD , BYVAL Flags AS QUAD , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegConnectRegistryEx = RegConnectRegistryExW
#ELSE
 MACRO RegConnectRegistryEx = RegConnectRegistryExA
#ENDIF
DECLARE FUNCTION RegCreateKeyA LIB "advapi32.dll" ALIAS "RegCreateKeyA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegCreateKeyW LIB "advapi32.dll" ALIAS "RegCreateKeyW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegCreateKey = RegCreateKeyW
#ELSE
 MACRO RegCreateKey = RegCreateKeyA
#ENDIF
DECLARE FUNCTION RegCreateKeyExA LIB "advapi32.dll" ALIAS "RegCreateKeyExA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL Reserved AS QUAD , BYREF lpClass AS ASCIIZ , BYVAL dwOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYREF phkResult AS QUAD , OPTIONAL BYREF lpdwDisposition AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegCreateKeyExW LIB "advapi32.dll" ALIAS "RegCreateKeyExW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL Reserved AS QUAD , BYREF lpClass AS WSTRINGZ , BYVAL dwOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYREF phkResult AS QUAD , OPTIONAL BYREF lpdwDisposition AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegCreateKeyEx = RegCreateKeyExW
#ELSE
 MACRO RegCreateKeyEx = RegCreateKeyExA
#ENDIF
DECLARE FUNCTION RegDeleteKeyA LIB "advapi32.dll" ALIAS "RegDeleteKeyA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDeleteKeyW LIB "advapi32.dll" ALIAS "RegDeleteKeyW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegDeleteKey = RegDeleteKeyW
#ELSE
 MACRO RegDeleteKey = RegDeleteKeyA
#ENDIF
DECLARE FUNCTION RegCreateKeyTransactedA LIB "advapi32.dll" ALIAS "RegCreateKeyTransactedA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL Reserved AS QUAD , BYREF lpClass AS ASCIIZ , BYVAL dwOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYREF phkResult AS QUAD , BYREF lpdwDisposition AS QUAD , BYVAL hTransaction AS QUAD , BYVAL pExtendedParemeter AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegCreateKeyTransactedW LIB "advapi32.dll" ALIAS "RegCreateKeyTransactedW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL Reserved AS QUAD , BYREF lpClass AS WSTRINGZ , BYVAL dwOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYREF phkResult AS QUAD , BYREF lpdwDisposition AS QUAD , BYVAL hTransaction AS QUAD , BYVAL pExtendedParemeter AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegCreateKeyTransacted = RegCreateKeyTransactedW
#ELSE
 MACRO RegCreateKeyTransacted = RegCreateKeyTransactedA
#ENDIF
DECLARE FUNCTION RegDeleteKeyExA LIB "advapi32.dll" ALIAS "RegDeleteKeyExA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL samDesired AS REGSAM , BYVAL Reserved AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDeleteKeyExW LIB "advapi32.dll" ALIAS "RegDeleteKeyExW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL samDesired AS REGSAM , BYVAL Reserved AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegDeleteKeyEx = RegDeleteKeyExW
#ELSE
 MACRO RegDeleteKeyEx = RegDeleteKeyExA
#ENDIF
DECLARE FUNCTION RegDeleteKeyTransactedA LIB "advapi32.dll" ALIAS "RegDeleteKeyTransactedA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL samDesired AS REGSAM , BYVAL Reserved AS QUAD , BYVAL hTransaction AS QUAD , BYVAL pExtendedParameter AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDeleteKeyTransactedW LIB "advapi32.dll" ALIAS "RegDeleteKeyTransactedW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL samDesired AS REGSAM , BYVAL Reserved AS QUAD , BYVAL hTransaction AS QUAD , BYVAL pExtendedParameter AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegDeleteKeyTransacted = RegDeleteKeyTransactedW
#ELSE
 MACRO RegDeleteKeyTransacted = RegDeleteKeyTransactedA
#ENDIF
DECLARE FUNCTION RegDisableReflectionKey LIB "advapi32.dll" ALIAS "RegDisableReflectionKey" ( BYVAL hBase AS QUAD ) AS LONG
DECLARE FUNCTION RegEnableReflectionKey LIB "advapi32.dll" ALIAS "RegEnableReflectionKey" ( BYVAL hBase AS QUAD
 ) AS LONG
DECLARE FUNCTION RegQueryReflectionKey LIB "advapi32.dll" ALIAS "RegQueryReflectionKey" ( BYVAL hBase AS DWORD
 , BYREF bIsReflectionDisabled AS LONG
 ) AS LONG
DECLARE FUNCTION RegDeleteValueA LIB "advapi32.dll" ALIAS "RegDeleteValueA" ( BYVAL hKey AS DWORD
 , OPTIONAL BYREF lpValueName AS ASCIIZ
 ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDeleteValueW LIB "advapi32.dll" ALIAS "RegDeleteValueW" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpValueName AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegDeleteValue = RegDeleteValueW
#ELSE
 MACRO RegDeleteValue = RegDeleteValueA
#ENDIF
DECLARE FUNCTION RegEnumKeyA LIB "advapi32.dll" ALIAS "RegEnumKeyA" ( BYVAL hKey AS QUAD , BYVAL dwIndex AS QUAD , BYREF lpName AS ASCIIZ , BYVAL cchName AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegEnumKeyW LIB "advapi32.dll" ALIAS "RegEnumKeyW" ( BYVAL hKey AS QUAD , BYVAL dwIndex AS QUAD , BYREF lpName AS WSTRINGZ , BYVAL cchName AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegEnumKey = RegEnumKeyW
#ELSE
 MACRO RegEnumKey = RegEnumKeyA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegEnumKeyExA LIB "AdvApi32.dll" ALIAS "RegEnumKeyExA" (BYVAL hKey AS QUAD, BYVAL dwIndex AS QUAD, lpName AS ASCIIZ, lpcbName AS QUAD, lpReserved AS QUAD, lpClass AS ASCIIZ, lpcbClass AS LONG, lpftLastWriteTime AS FILETIME) AS LONG
#ELSE
DECLARE FUNCTION RegEnumKeyExA LIB "advapi32.dll" ALIAS "RegEnumKeyExA" ( BYVAL hKey AS QUAD , BYVAL dwIndex AS QUAD , BYREF lpName AS ASCIIZ , BYREF lpcchName AS QUAD , OPTIONAL BYVAL lpReserved AS QUAD , OPTIONAL BYREF lpClass AS ASCIIZ , OPTIONAL BYREF lpcchClass AS QUAD , OPTIONAL BYREF lpftLastWriteTime AS FILETIME ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegEnumKeyExW LIB "AdvApi32.dll" ALIAS "RegEnumKeyExW" (BYVAL hKey AS QUAD, BYVAL dwIndex AS QUAD, lpName AS WSTRINGZ, lpcbName AS QUAD, lpReserved AS QUAD, lpClass AS WSTRINGZ, lpcbClass AS LONG, lpftLastWriteTime AS FILETIME) AS LONG
#ELSE
DECLARE FUNCTION RegEnumKeyExW LIB "advapi32.dll" ALIAS "RegEnumKeyExW" ( BYVAL hKey AS QUAD , BYVAL dwIndex AS QUAD , BYREF lpName AS WSTRINGZ , BYREF lpcchName AS QUAD , OPTIONAL BYVAL lpReserved AS QUAD , OPTIONAL BYREF lpClass AS WSTRINGZ , OPTIONAL BYREF lpcchClass AS QUAD , OPTIONAL BYREF lpftLastWriteTime AS FILETIME ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%UNICODE)
 MACRO RegEnumKeyEx = RegEnumKeyExW
#ELSE
 MACRO RegEnumKeyEx = RegEnumKeyExA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegEnumValueA LIB "AdvApi32.dll" ALIAS "RegEnumValueA" (BYVAL hKey AS QUAD, BYVAL dwIndex AS QUAD, lpValueName AS ASCIIZ, lpcbValueName AS QUAD, lpReserved AS QUAD, lpType AS QUAD, lpData AS ANY, lpcbData AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegEnumValueA LIB "advapi32.dll" ALIAS "RegEnumValueA" ( BYVAL hKey AS QUAD , BYVAL dwIndex AS QUAD , BYREF lpValueName AS ASCIIZ , BYREF lpcchValueName AS QUAD , OPTIONAL BYVAL lpReserved AS QUAD , OPTIONAL BYREF lpType AS QUAD , OPTIONAL BYREF lpData AS ANY , OPTIONAL BYREF lpcbData AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegEnumValueW LIB "AdvApi32.dll" ALIAS "RegEnumValueW" (BYVAL hKey AS QUAD, BYVAL dwIndex AS QUAD, lpValueName AS WSTRINGZ, lpcbValueName AS QUAD, lpReserved AS QUAD, lpType AS QUAD, lpData AS ANY, lpcbData AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegEnumValueW LIB "advapi32.dll" ALIAS "RegEnumValueW" ( BYVAL hKey AS QUAD , BYVAL dwIndex AS QUAD , BYREF lpValueName AS WSTRINGZ , BYREF lpcchValueName AS QUAD , OPTIONAL BYVAL lpReserved AS QUAD , OPTIONAL BYREF lpType AS QUAD , OPTIONAL BYREF lpData AS ANY , OPTIONAL BYREF lpcbData AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%UNICODE)
 MACRO RegEnumValue = RegEnumValueW
#ELSE
 MACRO RegEnumValue = RegEnumValueA
#ENDIF
DECLARE FUNCTION RegFlushKey LIB "advapi32.dll" ALIAS "RegFlushKey" ( BYVAL hKey AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegGetKeySecurity LIB "AdvApi32.dll" ALIAS "RegGetKeySecurity" (BYVAL hKey AS QUAD, BYVAL SecurityInformation AS LONG, pSecurityDescriptor AS QUAD, lpcbSecurityDescriptor AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegGetKeySecurity LIB "advapi32.dll" ALIAS "RegGetKeySecurity" ( BYVAL hKey AS QUAD , BYVAL SecurityInformation AS SECURITY_INFORMATION , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF lpcbSecurityDescriptor AS QUAD ) AS LONG ' LSTATUS
#ENDIF
DECLARE FUNCTION RegLoadKeyA LIB "advapi32.dll" ALIAS "RegLoadKeyA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYREF lpFile AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegLoadKeyW LIB "advapi32.dll" ALIAS "RegLoadKeyW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYREF lpFile AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegLoadKey = RegLoadKeyW
#ELSE
 MACRO RegLoadKey = RegLoadKeyA
#ENDIF
DECLARE FUNCTION RegNotifyChangeKeyValue LIB "advapi32.dll" ALIAS "RegNotifyChangeKeyValue" ( BYVAL hKey AS QUAD , BYVAL bWatchSubtree AS LONG , BYVAL dwNotifyFilter AS QUAD , BYVAL hEvent AS QUAD , BYVAL fAsynchronous AS LONG ) AS LONG ' LSTATUS
DECLARE FUNCTION RegOpenKeyA LIB "advapi32.dll" ALIAS "RegOpenKeyA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegOpenKeyW LIB "advapi32.dll" ALIAS "RegOpenKeyW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegOpenKey = RegOpenKeyW
#ELSE
 MACRO RegOpenKey = RegOpenKeyA
#ENDIF
DECLARE FUNCTION RegOpenKeyExA LIB "advapi32.dll" ALIAS "RegOpenKeyExA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL ulOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegOpenKeyExW LIB "advapi32.dll" ALIAS "RegOpenKeyExW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL ulOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF phkResult AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegOpenKeyEx = RegOpenKeyExW
#ELSE
 MACRO RegOpenKeyEx = RegOpenKeyExA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegOpenKeyTransactedA LIB "AdvApi32.dll" ALIAS "RegOpenKeyTransactedA" (BYVAL hKey AS QUAD, lpSubKey AS ASCIIZ, BYVAL ulOptions AS QUAD, BYVAL samDesired AS QUAD, phkResult AS QUAD, BYVAL hTransaction AS QUAD, pExtendedParameter AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegOpenKeyTransactedA LIB "advapi32.dll" ALIAS "RegOpenKeyTransactedA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL ulOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF phkResult AS QUAD , BYVAL hTransaction AS QUAD , BYVAL pExtendedParemeter AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegOpenKeyTransactedW LIB "AdvApi32.dll" ALIAS "RegOpenKeyTransactedW" (BYVAL hKey AS QUAD, lpSubKey AS WSTRINGZ, BYVAL ulOptions AS QUAD, BYVAL samDesired AS QUAD, phkResult AS QUAD, BYVAL hTransaction AS QUAD, pExtendedParameter AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegOpenKeyTransactedW LIB "advapi32.dll" ALIAS "RegOpenKeyTransactedW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL ulOptions AS QUAD , BYVAL samDesired AS REGSAM , BYREF phkResult AS QUAD , BYVAL hTransaction AS QUAD , BYVAL pExtendedParemeter AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%UNICODE)
 MACRO RegOpenKeyTransacted = RegOpenKeyTransactedW
#ELSE
 MACRO RegOpenKeyTransacted = RegOpenKeyTransactedA
#ENDIF
DECLARE FUNCTION RegQueryInfoKeyA LIB "advapi32.dll" ALIAS "RegQueryInfoKeyA" ( BYVAL hKey AS QUAD , BYREF lpClass AS ASCIIZ , OPTIONAL BYREF lpcchClass AS QUAD , OPTIONAL BYREF lpReserved AS QUAD , OPTIONAL BYREF lpcSubKeys AS QUAD , OPTIONAL BYREF lpcbMaxSubKeyLen AS QUAD , OPTIONAL BYREF lpcbMaxClassLen AS QUAD , OPTIONAL BYREF lpcValues AS QUAD , OPTIONAL BYREF lpcbMaxValueNameLen AS QUAD , OPTIONAL BYREF lpcbMaxValueLen AS QUAD , OPTIONAL BYREF lpcbSecurityDescriptor AS QUAD , OPTIONAL BYREF lpftLastWriteTime AS FILETIME ) AS LONG ' LSTATUS
DECLARE FUNCTION RegQueryInfoKeyW LIB "advapi32.dll" ALIAS "RegQueryInfoKeyW" ( BYVAL hKey AS QUAD , BYREF lpClass AS WSTRINGZ , OPTIONAL BYREF lpcchClass AS QUAD , OPTIONAL BYREF lpReserved AS QUAD , OPTIONAL BYREF lpcSubKeys AS QUAD , OPTIONAL BYREF lpcbMaxSubKeyLen AS QUAD , OPTIONAL BYREF lpcbMaxClassLen AS QUAD , OPTIONAL BYREF lpcValues AS QUAD , OPTIONAL BYREF lpcbMaxValueNameLen AS QUAD , OPTIONAL BYREF lpcbMaxValueLen AS QUAD , OPTIONAL BYREF lpcbSecurityDescriptor AS QUAD , OPTIONAL BYREF lpftLastWriteTime AS FILETIME ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegQueryInfoKey = RegQueryInfoKeyW
#ELSE
 MACRO RegQueryInfoKey = RegQueryInfoKeyA
#ENDIF
DECLARE FUNCTION RegQueryValueA LIB "advapi32.dll" ALIAS "RegQueryValueA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , OPTIONAL BYREF lpData AS ASCIIZ , OPTIONAL BYREF lpcbData AS LONG ) AS LONG ' LSTATUS
DECLARE FUNCTION RegQueryValueW LIB "advapi32.dll" ALIAS "RegQueryValueW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , OPTIONAL BYREF lpData AS WSTRINGZ , OPTIONAL BYREF lpcbData AS LONG ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegQueryValue = RegQueryValueW
#ELSE
 MACRO RegQueryValue = RegQueryValueA
#ENDIF
'#if(WINVER >= 0x0400)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegQueryMultipleValuesA LIB "AdvApi32.dll" ALIAS "RegQueryMultipleValuesA" (BYVAL hKey AS QUAD, BYVAL pvallist AS VALENTA PTR, BYVAL numvals AS QUAD, lpValueBuf AS ASCIIZ, pdwTotSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegQueryMultipleValuesA LIB "advapi32.dll" ALIAS "RegQueryMultipleValues" ( BYVAL hKey AS QUAD , BYREF val_list AS VALENTA , BYVAL num_vals AS QUAD , OPTIONAL BYREF lpValueBuf AS ASCIIZ , OPTIONAL BYREF ldwTotsize AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegQueryMultipleValuesW LIB "AdvApi32.dll" ALIAS "RegQueryMultipleValuesW" (BYVAL hKey AS QUAD, BYVAL pvallist AS VALENTW PTR, BYVAL numvals AS QUAD, lpValueBuf AS WSTRINGZ, pdwTotSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegQueryMultipleValuesW LIB "advapi32.dll" ALIAS "RegQueryMultipleValuesW" ( BYVAL hKey AS QUAD , BYREF val_list AS VALENTW , BYVAL num_vals AS QUAD , OPTIONAL BYREF lpValueBuf AS WSTRINGZ , OPTIONAL BYREF ldwTotsize AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%UNICODE)
 MACRO RegQueryMultipleValues = RegQueryMultipleValuesW
#ELSE
 MACRO RegQueryMultipleValues = RegQueryMultipleValuesA
#ENDIF
DECLARE FUNCTION RegQueryValueExA LIB "advapi32.dll" ALIAS "RegQueryValueExA" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpValueName AS ASCIIZ , OPTIONAL BYVAL lpReserved AS QUAD , OPTIONAL BYREF lpType AS QUAD , OPTIONAL BYREF lpData AS ANY , OPTIONAL BYREF lpcbData AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegQueryValueExW LIB "advapi32.dll" ALIAS "RegQueryValueExW" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpValueName AS WSTRINGZ , OPTIONAL BYVAL lpReserved AS QUAD , OPTIONAL BYREF lpType AS QUAD , OPTIONAL BYREF lpData AS ANY , OPTIONAL BYREF lpcbData AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegQueryValueEx = RegQueryValueExW
#ELSE
 MACRO RegQueryValueEx = RegQueryValueExA
#ENDIF
DECLARE FUNCTION RegReplaceKeyA LIB "advapi32.dll" ALIAS "RegReplaceKeyA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYREF lpNewFile AS ASCIIZ , BYREF lpOldFile AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegReplaceKeyW LIB "advapi32.dll" ALIAS "RegReplaceKeyW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYREF lpNewFile AS WSTRINGZ , BYREF lpOldFile AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegReplaceKey = RegReplaceKeyW
#ELSE
 MACRO RegReplaceKey = RegReplaceKeyA
#ENDIF
DECLARE FUNCTION RegRestoreKeyA LIB "advapi32.dll" ALIAS "RegRestoreKeyA" ( BYVAL hKey AS QUAD , BYREF lpFile AS ASCIIZ , BYVAL dwFlags AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegRestoreKeyW LIB "advapi32.dll" ALIAS "RegRestoreKeyW" ( BYVAL hKey AS QUAD , BYREF lpFile AS WSTRINGZ , BYVAL dwFlags AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegRestoreKey = RegRestoreKeyW
#ELSE
 MACRO RegRestoreKey = RegRestoreKeyA
#ENDIF
'#if(WINVER >= 0x0600)
DECLARE FUNCTION RegRenameKey LIB "advapi32.dll" ALIAS "RegRenameKey" ( BYVAL hKey AS QUAD , BYREF lpSubKeyName AS WSTRINGZ , BYREF lpNewKeyName AS WSTRINGZ ) AS LONG ' LSTATUS
'#endif /* WINVER >= 0x0600 */
DECLARE FUNCTION RegSaveKeyA LIB "advapi32.dll" ALIAS "RegSaveKeyA" ( BYVAL hKey AS QUAD , BYREF lpFile AS ASCIIZ , OPTIONAL BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS LONG ' LSTATUS
DECLARE FUNCTION RegSaveKeyW LIB "advapi32.dll" ALIAS "RegSaveKeyW" ( BYVAL hKey AS QUAD , BYREF lpFile AS WSTRINGZ , OPTIONAL BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegSaveKey = RegSaveKeyW
#ELSE
 MACRO RegSaveKey = RegSaveKeyA
#ENDIF
DECLARE FUNCTION RegSetKeySecurity LIB "advapi32.dll" ALIAS "RegSetKeySecurity" ( BYVAL hKey AS QUAD , BYVAL SecurityInformation AS SECURITY_INFORMATION , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR ) AS LONG ' LSTATUS
DECLARE FUNCTION RegSetValueA LIB "advapi32.dll" ALIAS "RegSetValueA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL dwType AS QUAD , BYREF lpData AS ASCIIZ , BYVAL cbData AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegSetValueW LIB "advapi32.dll" ALIAS "RegSetValueW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL dwType AS QUAD , BYREF lpData AS WSTRINGZ , BYVAL cbData AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegSetValue = RegSetValueW
#ELSE
 MACRO RegSetValue = RegSetValueA
#ENDIF
DECLARE FUNCTION RegSetValueExA LIB "advapi32.dll" ALIAS "RegSetValueExA" ( BYVAL hKey AS QUAD , BYREF lpValueName AS ASCIIZ , BYVAL Reserved AS QUAD , BYVAL dwType AS QUAD , BYREF lpData AS ANY , BYVAL cbData AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegSetValueExW LIB "advapi32.dll" ALIAS "RegSetValueExW" ( BYVAL hKey AS QUAD , BYREF lpValueName AS WSTRINGZ , BYVAL Reserved AS QUAD , BYVAL dwType AS QUAD , BYREF lpData AS ANY , BYVAL cbData AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegSetValueEx = RegSetValueExW
#ELSE
 MACRO RegSetValueEx = RegSetValueExA
#ENDIF
DECLARE FUNCTION RegUnLoadKeyA LIB "advapi32.dll" ALIAS "RegUnLoadKeyA" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegUnLoadKeyW LIB "advapi32.dll" ALIAS "RegUnLoadKeyW" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegUnLoadKey = RegUnLoadKeyW
#ELSE
 MACRO RegUnLoadKey = RegUnLoadKeyA
#ENDIF
'//
'// Utils wrappers
'//
'#if _WIN32_WINNT >= 0x0600
DECLARE FUNCTION RegDeleteKeyValueA LIB "advapi32.dll" ALIAS "RegDeleteKeyValueA" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS ASCIIZ , OPTIONAL BYREF lpValueName AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDeleteKeyValueW LIB "advapi32.dll" ALIAS "RegDeleteKeyValueW" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS WSTRINGZ , OPTIONAL BYREF lpValueName AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegDeleteKeyValue = RegDeleteKeyValueW
#ELSE
 MACRO RegDeleteKeyValue = RegDeleteKeyValueA
#ENDIF
DECLARE FUNCTION RegSetKeyValueA LIB "advapi32.dll" ALIAS "RegSetKeyValueA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYREF lpValueName AS ASCIIZ , BYVAL dwType AS QUAD , BYREF lpData AS ANY , BYVAL cbData AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegSetKeyValueW LIB "advapi32.dll" ALIAS "RegSetKeyValueW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYREF lpValueName AS WSTRINGZ , BYVAL dwType AS QUAD , BYREF lpData AS ANY , BYVAL cbData AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegSetKeyValue = RegSetKeyValueW
#ELSE
 MACRO RegSetKeyValue = RegSetKeyValueA
#ENDIF
DECLARE FUNCTION RegDeleteTreeA LIB "advapi32.dll" ALIAS "RegDeleteTreeA" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegDeleteTreeW LIB "advapi32.dll" ALIAS "RegDeleteTreeW" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegDeleteTree = RegDeleteTreeW
#ELSE
 MACRO RegDeleteTree = RegDeleteTreeA
#ENDIF
DECLARE FUNCTION RegCopyTreeA LIB "advapi32.dll" ALIAS "RegCopyTreeA" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS ASCIIZ , BYVAL hKeyDest AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegCopyTreeW LIB "advapi32.dll" ALIAS "RegCopyTreeW" ( BYVAL hKey AS QUAD , BYREF lpSubKey AS WSTRINGZ , BYVAL hKeyDest AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegCopyTree = RegCopyTreeW
#ELSE
 MACRO RegCopyTree = RegCopyTreeA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegGetValueA LIB "AdvApi32.dll" ALIAS "RegGetValueA" (BYVAL hKey AS QUAD, lpSubKey AS ASCIIZ, lpValue AS ASCIIZ, BYVAL dwFlags AS QUAD, pdwType AS QUAD, pvData AS QUAD, pcbData AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegGetValueA LIB "advapi32.dll" ALIAS "RegGetValueA" ( BYVAL hKey AS QUAD , OPTIONAL BYREF lpSubKey AS ASCIIZ , OPTIONAL BYREF lpValue AS ASCIIZ , OPTIONAL BYVAL dwFlags AS QUAD , OPTIONAL BYREF pdwType AS QUAD , OPTIONAL BYREF pvData AS ANY , OPTIONAL BYREF pcbData AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION RegGetValueW LIB "AdvApi32.dll" ALIAS "RegGetValueW" (BYVAL hKey AS QUAD, lpSubKey AS WSTRINGZ, lpValue AS WSTRINGZ, BYVAL dwFlags AS QUAD, pdwType AS QUAD, pvData AS QUAD, pcbData AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION RegGetValueW LIB "advapi32.dll" ALIAS "RegGetValueW" ( BYVAL hkey AS QUAD , OPTIONAL BYREF lpSubKey AS WSTRINGZ , OPTIONAL BYREF lpValue AS WSTRINGZ , OPTIONAL BYVAL dwFlags AS QUAD , OPTIONAL BYREF pdwType AS QUAD , OPTIONAL BYREF pvData AS ANY , OPTIONAL BYREF pcbData AS QUAD ) AS LONG ' LSTATUS
#ENDIF
#IF %DEF(%UNICODE)
 MACRO RegGetValue = RegGetValueW
#ELSE
 MACRO RegGetValue = RegGetValueA
#ENDIF
DECLARE FUNCTION RegLoadMUIStringA LIB "advapi32.dll" ALIAS "RegLoadMUIStringA" ( BYVAL hKey AS QUAD , BYREF pszValue AS ASCIIZ , BYREF pszOutBuf AS ASCIIZ , BYVAL cbOutBuf AS QUAD , BYREF pcbData AS QUAD , BYVAL Flags AS QUAD , OPTIONAL BYREF pszDirectory AS ASCIIZ ) AS LONG ' LSTATUS
DECLARE FUNCTION RegLoadMUIStringW LIB "advapi32.dll" ALIAS "RegLoadMUIStringW" ( BYVAL hKey AS QUAD , BYREF pszValue AS WSTRINGZ , BYREF pszOutBuf AS WSTRINGZ , BYVAL cbOutBuf AS QUAD , BYREF pcbData AS QUAD , BYVAL Flags AS QUAD , OPTIONAL BYREF pszDirectory AS WSTRINGZ ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegLoadMUIString = RegLoadMUIStringW
#ELSE
 MACRO RegLoadMUIString = RegLoadMUIStringA
#ENDIF
DECLARE FUNCTION RegLoadAppKeyA LIB "advapi32.dll" ALIAS "RegLoadAppKeyA" ( BYREF lpFile AS ASCIIZ , BYREF phkResult AS QUAD , BYVAL samDesired AS REGSAM , BYVAL dwOptions AS QUAD , BYVAL Reserved AS QUAD ) AS LONG ' LSTATUS
DECLARE FUNCTION RegLoadAppKeyW LIB "advapi32.dll" ALIAS "RegLoadAppKeyW" ( BYREF lpFile AS WSTRINGZ , BYREF phkResult AS QUAD , BYVAL samDesired AS REGSAM , BYVAL dwOptions AS QUAD , BYVAL Reserved AS QUAD ) AS LONG ' LSTATUS
#IF %DEF(%UNICODE)
 MACRO RegLoadAppKey = RegLoadAppKeyW
#ELSE
 MACRO RegLoadAppKey = RegLoadAppKeyA
#ENDIF
'#endif // _WIN32_WINNT >= 0x0600
'//
'// Remoteable System Shutdown APIs
'//
DECLARE FUNCTION InitiateSystemShutdownA LIB "advapi32.dll" ALIAS "InitiateSystemShutdownA" ( BYREF lpMachineName AS ASCIIZ , BYREF lpMessage AS ASCIIZ , BYVAL dwTimeout AS QUAD , BYVAL bForceAppsClosed AS LONG , BYVAL bRebootAfterShutdown AS LONG ) AS LONG
DECLARE FUNCTION InitiateSystemShutdownW LIB "advapi32.dll" ALIAS "InitiateSystemShutdownW" ( BYREF lpMachineName AS WSTRINGZ
 , BYREF lpMessage AS WSTRINGZ
 , BYVAL dwTimeout AS DWORD
 , BYVAL bForceAppsClosed AS LONG
 , BYVAL bRebootAfterShutdown AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO InitiateSystemShutdown = InitiateSystemShutdownW
#ELSE
 MACRO InitiateSystemShutdown = InitiateSystemShutdownA
#ENDIF
DECLARE FUNCTION AbortSystemShutdownA LIB "advapi32.dll" ALIAS "AbortSystemShutdownA" ( OPTIONAL BYREF lpMachineName AS ASCIIZ ) AS LONG
DECLARE FUNCTION AbortSystemShutdownW LIB "advapi32.dll" ALIAS "AbortSystemShutdownW" ( OPTIONAL BYREF lpMachineName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO AbortSystemShutdown = AbortSystemShutdownW
#ELSE
 MACRO AbortSystemShutdown = AbortSystemShutdownA
#ENDIF
'//
'// defines for InitiateSystemShutdownEx reason codes
'//
#INCLUDE ONCE "Legacy/System/Reason.inc"
'//
'// Then for Historical reasons support some old symbols, internal only
%EQUATE `REASON_SWINSTALL = %SHTDN_REASON_MAJOR_SOFTWARE OR %SHTDN_REASON_MINOR_INSTALLATION
%EQUATE `REASON_HWINSTALL = %SHTDN_REASON_MAJOR_HARDWARE OR %SHTDN_REASON_MINOR_INSTALLATION
%EQUATE `REASON_SERVICEHANG = %SHTDN_REASON_MAJOR_SOFTWARE OR %SHTDN_REASON_MINOR_HUNG
%EQUATE `REASON_UNSTABLE = %SHTDN_REASON_MAJOR_SYSTEM OR %SHTDN_REASON_MINOR_UNSTABLE
%EQUATE `REASON_SWHWRECONF = %SHTDN_REASON_MAJOR_SOFTWARE OR %SHTDN_REASON_MINOR_RECONFIG
%EQUATE `REASON_OTHER = %SHTDN_REASON_MAJOR_OTHER OR %SHTDN_REASON_MINOR_OTHER
%EQUATE `REASON_UNKNOWN = %SHTDN_REASON_UNKNOWN
%EQUATE `REASON_LEGACY_API = %SHTDN_REASON_LEGACY_API
%EQUATE `REASON_PLANNED_FLAG = %SHTDN_REASON_FLAG_PLANNED
'//
'// MAX Shutdown TimeOut == 10 Years in seconds
'//
%EQUATE `MAX_SHUTDOWN_TIMEOUT = (10*365*24*60*60)
DECLARE FUNCTION InitiateSystemShutdownExA LIB "advapi32.dll" ALIAS "InitiateSystemShutdownExA" ( BYREF lpMachineName AS ASCIIZ , BYREF lpMessage AS ASCIIZ , BYVAL dwTimeout AS QUAD , BYVAL bForceAppsClosed AS LONG , BYVAL bRebootAfterShutdown AS LONG , BYVAL dwReason AS QUAD ) AS LONG
DECLARE FUNCTION InitiateSystemShutdownExW LIB "advapi32.dll" ALIAS "InitiateSystemShutdownExW" ( BYREF lpMachineName AS WSTRINGZ
 , BYREF lpMessage AS WSTRINGZ
 , BYVAL dwTimeout AS DWORD
 , BYVAL bForceAppsClosed AS LONG
 , BYVAL bRebootAfterShutdown AS LONG
 , BYVAL dwReason AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO InitiateSystemShutdownEx = InitiateSystemShutdownExW
#ELSE
 MACRO InitiateSystemShutdownEx = InitiateSystemShutdownExA
#ENDIF
'//
'// Shutdown flags
'//
%EQUATE `SHUTDOWN_FORCE_OTHERS = &H00000001
%EQUATE `SHUTDOWN_FORCE_SELF = &H00000002
%EQUATE `SHUTDOWN_RESTART = &H00000004
%EQUATE `SHUTDOWN_POWEROFF = &H00000008
%EQUATE `SHUTDOWN_NOREBOOT = &H00000010
%EQUATE `SHUTDOWN_GRACE_OVERRIDE = &H00000020
%EQUATE `SHUTDOWN_INSTALL_UPDATES = &H00000040
%EQUATE `SHUTDOWN_RESTARTAPPS = &H00000080
%EQUATE `SHUTDOWN_SKIP_SVC_PRESHUTDOWN = &H00000100
DECLARE FUNCTION InitiateShutdownA LIB "advapi32.dll" ALIAS "InitiateShutdownA" ( BYREF lpMachineName AS ASCIIZ , BYREF lpMessage AS ASCIIZ , BYVAL dwGracePeriod AS QUAD , BYVAL dwShutdownFlags AS QUAD , BYVAL dwReason AS QUAD ) AS QUAD
DECLARE FUNCTION InitiateShutdownW LIB "advapi32.dll" ALIAS "InitiateShutdownW" ( BYREF lpMachineName AS WSTRINGZ
 , BYREF lpMessage AS WSTRINGZ
 , BYVAL dwGracePeriod AS DWORD
 , BYVAL dwShutdownFlags AS DWORD
 , BYVAL dwReason AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO InitiateShutdown = InitiateShutdownW
#ELSE
 MACRO InitiateShutdown = InitiateShutdownA
#ENDIF
DECLARE FUNCTION RegSaveKeyExA LIB "advapi32.dll" ALIAS "RegSaveKeyExA" ( BYVAL hKey AS QUAD , BYREF lpFile AS ASCIIZ , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION RegSaveKeyExW LIB "advapi32.dll" ALIAS "RegSaveKeyExW" ( BYVAL hKey AS QUAD
 , BYREF lpFile AS WSTRINGZ
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 , BYVAL Flags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO RegSaveKeyEx = RegSaveKeyExW
#ELSE
 MACRO RegSaveKeyEx = RegSaveKeyExA
#ENDIF
' // Removed in Windows 7 SDK
'DECLARE FUNCTION Wow64Win32ApiEntry LIB "advapi32.dll" ALIAS "Wow64Win32ApiEntry" ( ' BYVAL dwFuncNumber AS DWORD
' , BYVAL dwFlag AS DWORD
' , BYVAL dwRes AS DWORD
' ) AS LONG
#ENDIF
