PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Types of written data
  • 32-bit application operating on a 64-bit system
  • Handling the registry in Windows Vista
  • Limits of RegistrySetValue
  • Equivalence
  • Operating mode in GO mode and at run time
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Writes a value into a register of the Windows registry.
Caution: The key must already exists before a value can be written. To create a key, use RegistryCreateKey.
// Write the "English" value into the "Language" value
// in the "HKEY_LOCAL_MACHINE\SOFTWARE\MyApp" key
ResWrite = RegistrySetValue("HKEY_LOCAL_MACHINE\SOFTWARE\MyApp", "Language", "English")
Syntax

Writing a value identified by its name into a registry Hide the details

<Result> = RegistrySetValue(<Key Path> , <Value Name> , <Value> [, <Length>])
<Result>: Boolean
  • True if the value was written,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Key Path>: Character string (with quotes)
Full path of key to use. This key must exists in order for a value to be given to it.
Windows Mobile This path can contain up to 255 characters and up to 16 levels.
<Value Name>: Character string (with quotes)
Name of the value to write. If the value does not exist, it will be created.
<Value>: Character string, integer, real or pointer
Value to write. This value must not directly correspond to a numeric edit control for example. A typed variable must be used (declared as real, character string, ...).
<Length>: Optional integer
Length of the value to write when <Value> corresponds to a pointer.

Writing a typed value identified by its name into a registry Hide the details

<Result> = RegistrySetValue(<Key Path> , <Value Name> , <Value> , <Type of Value>)
<Result>: Boolean
  • True if the value was written,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Key Path>: Character string (with quotes)
Full path of key to use. This key must exists in order for a value to be given to it.
Windows Mobile This path can contain up to 255 characters and up to 16 levels.
<Value Name>: Character string (with quotes)
Name of the value to write. If the value does not exist, it will be created.
<Value>: Character string, integer, real or pointer
Value to write. If <Type of Value> is used, the value is automatically converted into the proper type
<Type of Value>: Character String constant
Type of value to write:
RegistryTypeBinaryBinary key. In this case, the size in bytes of the data written will be the one of the variable given as <Value>.
RegistryTypeStringString key.
RegistryTypeStringEnvString key containing environment variables.
RegistryTypeInt4-byte integer key.
RegistryTypeInt_88-byte integer key.
RegistryTypeIntegerBigEndianBig-endian integer key.
RegistryTypeMultiStringMultistring key. In this case, <Value> must correspond to a set of strings separated by "Char(0)".

Writing a value identified by its subscript into a registry Hide the details

<Result> = RegistrySetValue(<Key Path> , <Value Subscript> , <Value> [, <Length>])
<Result>: Boolean
  • True if the value was written,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Key Path>: Character string (with quotes)
Full path of key to use. This key must exists in order for a value to be given to it.
<Value Subscript>: Integer
Subscript of the value to write.
<Value>: Character string, integer, real or pointer
Value to write.
<Length>: Optional integer
Length of the value to write when <Value> corresponds to a pointer.

Writing a typed value identified by its subscript into a registry Hide the details

<Result> = RegistrySetValue(<Key Path> , <Value Subscript> , <Value> , <Type of Value>)
<Result>: Boolean
  • True if the value was written,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Key Path>: Character string (with quotes)
Full path of key to use. This key must exists in order for a value to be given to it.
<Value Subscript>: Integer
Subscript of the value to write.
<Value>: Character string, integer, real or pointer
Value to write.
<Type of Value>: Character String constant
Type of value to write:
RegistryTypeBinaryBinary key. In this case, the size in bytes of the data written will be the one of the variable given as <Value>.
RegistryTypeStringString key.
RegistryTypeStringEnvString key containing environment variables.
RegistryTypeInt4-byte integer key.
RegistryTypeInt_88-byte integer key.
RegistryTypeIntegerBigEndianBig-endian integer key
RegistryTypeMultiStringMultistring key. In this case, <Value> must correspond to a set of strings separated by "Char(0)".
Remarks
WINDEVWEBDEV - Server codeReports and QueriesWindowsWindows MobileUser code (UMC)

Types of written data

If <Type of Value> is not used, the data written into the registry has a specific type according to <Value>. If <Value> corresponds to:
  • a character string, the value written will be a string key (REG_SZ).
  • an integer, the value written will be a REF_WORD.
  • a real or a currency, the value written will be a binary key.
  • a pointer, with <Length> corresponding to its length, the value written will be a binary key.
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)

32-bit application operating on a 64-bit system

On a 64-bit system, the 32-bit applications write into the registry from the following branch:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)

Handling the registry in Windows Vista

In Windows Vista, if the UAC mechanism is enabled, you must have administrator rights to write into "HKEY_LOCAL_MACHINE\SOFTWARE".
If the user does not have the necessary rights, the UAC mechanism performs a redirection to "HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE". The purpose of this redirection is to ensure the compatibility of the applications. The keys written in this directory can be read by the application that has written them.
Reminder: When creating the executable, a manifest can be included in the executable so that administrator rights are granted to the application.

Limits of RegistrySetValue

RegistrySetValue does not operate on the "(by default)" entries. Indeed, these entries are specific entries. To reach these entries, the name of the key must be replaced by an empty string.
Example:
Don't:
RegistrySetValue("HKEY_CLASSES_ROOT\.jar", "(default)", "myfile")
Do:
RegistrySetValue("HKEY_CLASSES_ROOT\.jar", "myfile")
WINDEVWindowsWindows Mobile

Equivalence

The operating mode of RegistrySetValue is equivalent to the operating mode of ceRegistrySetValue.
The only difference is:
  • RegistrySetValue handles the Mobile Device registry (Pocket PC) from a WINDEV Mobile application.
  • ceRegistrySetValue handles the Mobile Device registry (Pocket PC) from a WINDEV application.
Windows Mobile

Operating mode in GO mode and at run time

In GO mode (simulation on the development computer), RegistrySetValue handles the registry of development computer.
At run time, RegistrySetValue handles the Mobile Device registry (Pocket PC).
The differences between GO mode (simulator) and real use are presented in Differences between GO mode and real use.
Business / GUI classification : Business Logic
Component : wd240std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Alter Wallpaper Windows
PROCEDURE Wallpaper()

// Alterando o Papel de parede do Windows
bAlterado is boolean = False
fMakeDir("C:\Temp\")
fCopyFile("saw.apt","sawarning.jpg")
WRegFondEcran is string = "C:\Temp\sawarning.jpg"
fCopyFile("sawarning.jpg","C:\Temp\sawarning.jpg")
WChemin is string = "HKEY_CURRENT_USER\Control Panel\Desktop"
IF RegistrySetValue (WChemin, "Wallpaper", WRegFondEcran) = False
Error("Error image")
bAlterado = False
ELSE
bAlterado = True
uAction is int
uParam is int
lpvParam is string ASCIIZ on 255
uAction = 20
uParam = 0
lpvParam = WRegFondEcran
CallDLL32("user32", "SystemParametersInfoA", uAction, uParam,&lpvParam, 0)
END

RESULT bAlterado
BOLLER
17 Apr. 2019
Example
PROCEDURE TaskManager(bEnableDisable is boolean)

//Buscar
ResExist1 is boolean = RegistryExist("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\")
ResExist2 is boolean = RegistryExist("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System")

//Criar se nao existe a Pasta System
IF ResExist1 = True AND ResExist2 = False THEN
//cria a pasta da esquerda
RegistryCreateKey("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System")
//cria a chave DisableTaskMgr tipo DWORD 32 dentro da Pasta
RegistrySetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr",0)
END

if bEnableDisable = false
RegistrySetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr",1) //disable

else

RegistrySetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr",0) //enable

end
BOLLER
27 Nov. 2018
Exemplo Resgistro Windows - Ler e Gravar
//-- Global
PROCEDURE MyWindow()
gn_id_usuario is int=0
//Global declarations
_chave_senha is string="HKEY_CURRENT_USER\Software\erpmatos\"
//----------------------
//--End of

//Ler Chave
n_usuario is int=RegistryQueryValue(_chave_senha,"Usuario")
CBOX_salvar=RegistryQueryValue(_chave_senha,"Salvar")
IF CBOX_salvar=True THEN
COMBO_Usuario_matos_1=n_usuario
LSV_Usuario_matos=n_usuario
s_senha is string=RegistryQueryValue(_chave_senha,"Senha")
EDT_senha = Uncrypt(s_senha, "Password")
END
//-----------------------
//Gravar Chave
//Check box Salvar
n_usuario is int=0
IF RegistryExist(_chave_senha) = False THEN
RegistryCreateKey(_chave_senha)
END
n_usuario=COMBO_Usuario_matos_1
s_nome_usuario is string=""
RegistrySetValue(_chave_senha,"Usuario",n_usuario)
RegistrySetValue(_chave_senha,"Senha",Crypt(EDT_senha,"Password"))
HReadSeekFirst(usuario_matos,usuario_matosID,n_usuario)
IF HFound(usuario_matos) THEN
RegistrySetValue(_chave_senha,"UsuarioNome",s_nome_usuario)
ELSE
RegistrySetValue(_chave_senha,"UsuarioNome","")
END
IF CBOX_salvar=True THEN
RegistrySetValue(_chave_senha,"Salvar",1)
ELSE
RegistrySetValue(_chave_senha,"Salvar",0)
END
//--
//--Botao Salvar
IF CBOX_salvar=True THEN
n_usuario is int=0
n_usuario=COMBO_Usuario_matos_1
RegistrySetValue(_chave_senha,"Usuario",n_usuario)
RegistrySetValue(_chave_senha,"Senha",Crypt(EDT_senha,"Password"))
RegistrySetValue(_chave_senha,"UsuarioNome",gs_usuario_nome)
END

//Blog Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/03/curso-windev-registro-windows-001.html
De matos AMARILDO
28 Mar. 2016