ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Miscellaneous WINDEV functions
  • Reading the persistent values
  • Miscellaneous
  • Windows Vista (and later)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Reads the content of an INI file (or the content of a file structured like .INI files). You can get:
  • the value of a keyword found in a specific section,
  • the list of keywords found in a section,
  • the list of file sections.
Example of .INI file
[WD examples]
Name1 = WDInstall
Name2 = WDBench
[Description of WDInstall]
Caption = Use the control panel of Windows
LST = 43
Page = 12
Reports and Queries
// Read in the [WD Examples] section
INIRead("WD Examples", "Name2", "", "C:\Temp\ExamplesLST.INI")
// Default choice read in the .INI
nProduct is int = Val(INIRead("USER", ...
"LastProd", "", fExeDir() + "\Port.INI"))
IF nProduct > 0 THEN ListSelectPlus(LIST_Product, nProduct)
Syntax
<Result> = INIRead(<Section> [, <Keyword> [, <Not found> [, <File>]]])
<Result>: Character string
  • Text sought or list of keywords found in the section (the keywords are separated by CR characters),
  • List of file sections (the sections are separated by CR characters).
  • Content of <Not found> in the following cases:
    • the string corresponding to the keyword is empty,
    • the keyword is not found,
    • the file is not found.
  • Empty string (if <Not found> is not specified or if it is equal to an empty string) in the following cases:
    • the string corresponding to the keyword is empty,
    • the keyword is not found,
    • the file is not found.
<Section>: Character string
Name of section to read in the INI file.
If this parameter and <Keyword> correspond to an empty string, <Result> contains the list of sections found in the file, separated by CR characters.

Remark: This name cannot contain the "-" character.
<Keyword>: Optional character string
Name of the keyword containing the information to read.
If this parameter is an empty string, <Result> contains the list of keywords found in <Section>, separated by CR characters.
<Not found>: Optional character string or optional integer
Text or integer to be returned if the requested keyword has not been read. This parameter corresponds to an empty string by default.
<File>: Optional character string
Full name of file to read (with its extension).
  • The WIN.INI file will be used if this parameter is not specified.
  • If only the name of the file is specified, the specified file will be sought in the directory of Windows.
Remarks

Reading the persistent values

To read the persistent values in a INI file (saved with SaveParameter), use LoadParameter.

Miscellaneous

  • To read in the registry, use the functions specific to the registry: RegistryQueryValue, ...
  • INI files are limited to 64 KB.
  • TSE: Bu default, INIRead uses the Windows directory.
    Caution: Until version 21, INIRead used the user's Windows directory by default.
    Reminder: In TSE mode, the access to a '.INI' file with a relative name is not recommended. We advise you to use one of the following solutions:
Reports and Queries

Windows Vista (and later)

The programming standards of Windows do not advise you to write:
  • into the WIN.INI file,
  • into the system directories (Windows directory, "Program Files" directory, ...).
In Windows Vista (and later) with the UAC mechanism enabled, the administrator privileges are required to perform these operations. If the application does not have the required administrator privileges, the UAC mechanism will redirect the files (called virtualization) to a directory specific to the user who uses the application (C:\Users\<LOGIN>AppData\Local\VirtualStore\Windows\). Files can be read again with INIRead, used in the same application. This virtualization mechanism of files is proposed by Windows Vista (and later) for compatibility and it is not available in 64 bits.
Caution: If the INI file is automatically virtualized by Windows Vista (and later), the INI file cannot be shared between several applications (especially if these applications use different privileges).
Programming tip: To create a INI file without having the administrator privileges:
  • do not use the WIN.INI file (the <File> parameter must be specified)
  • avoid writing to the Windows directory or to the "Program Files" directory,
  • use the system directory of the application (returned by SysDir with the srAppDataCommun constant, for example).
Business / UI classification: Business Logic
Component: wd290std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
LER CAMPOS INI E TXT
EDT_Retorno_cStat=INIRead("EVENTO001","cStat","",EDT_localizacao_arquivo_retorno_carta)
EDT_Retorno_nProt=INIRead("EVENTO001","nProt","",EDT_localizacao_arquivo_retorno_carta)
//===
[EVENTO001]
cStat=135
//BLOG COM VIDE E EXEMPLO

AULA 1312 WINDEV DICAS 048 INIREAD

http://windevdesenvolvimento.blogspot.com.br/2017/12/aula-1312-windev-dicas-048-iniread.html

https://www.youtube.com/watch?v=5F7zQU9sBYQ
De matos
22 Dec. 2017

Last update: 04/07/2023

Send a report | Local help