Chapitre précédentRetour au sommaireChapitre suivant

Documentation VISION (VAPI)

Last update: 19/05/18


INI INTERFACE


Abstract
Interface Prefix In
Number of functions 6
Description Set of functions to manipulate INI files. A maximum of 3 INI files can be simulataneously managed.

 

Prototype long cdecl InOpen(char *file)
Parameters [IN] file : INI file name
Return If >= 0 : a INI handle
If < 0, No more INI handle available
Description Reserve a INI handle to operate later on. If file does not exist, a valid handle is returned, file can then be saved by calling InSaveAndClose.
Comments  
VAPI Version 1.02 or greater

 

Prototype long cdecl InClose(long hini)
Parameters [IN] hini : A INI handle previously returned by InOpen
Return 0 : Success
-1 : Invalid handle
Description Free INI handle. Does not save modifications, use InSaveAndClose to save them.
Comments  
VAPI Version 1.02 or greater

 

Prototype long cdecl InSaveAndClose(long hini, char *new_name)
Parameters [IN] hini : A INI handle previously returned by InOpen
[IN] new_name : new filename to use for saving. If NULL, this function will use the one passed to InOpen
Return 0 : Success
-1 : Invalid handle, won't save.
Description Generate a INI file by commiting all modifications made since last call to InOpen
Comments  
VAPI Version 1.02 or greater

 

Prototype long cdecl InGetKey(long hini, char *section, char *key, char *val_key)
Parameters [IN] hini : A INI handle previously returned by InOpen
[IN] section : section name
[IN] key : key name
[OUT] val_key : buffer which will hold the key value in ASCII
Return 0 : Error : key or section does not exist
1 : Success, ASCII value for this key in the section is hold in val_key
Description Retrieves a specific key in a specific section
Comments  
VAPI Version 1.02 or greater

 

Prototype long cdecl InSetKey(long hini, char *section, char *key, char *val_key)
Parameters [IN] hini : A INI handle previously returned by InOpen
[IN] section : section name
[IN] key : key name
[OUT] val_key : buffer which holds the key value in ASCII
Return 0 : Error : key or section could not be created or changed due to insufficient memory
1 : Success
Description Adds or modify a key within a section
Comments If section r key does not exist, it is created
VAPI Version 1.02 or greater

 

Prototype long cdecl InGetOrSetKey(long hini, char *section, char *key, char *val_key)
Parameters [IN] hini : A INI handle previously returned by InOpen
[IN] section : section name
[IN] key : key name
[IN/OUT] val_key : buffer holding the default key value in ASCII [IN] or/and the key value [OUT]
Return 0 : Key has been sucessfully retrieved
1 : Key has been created.
Description Used to retrieve an existing key in a given section or create it with a default value.
Comments Pretty useful!
VAPI Version 1.02 or greater

Prototype long InGetKeyFromFile(char *file, char *section, char *key, char *val_key)
Parameters [IN] file : INI file name
[IN] section : section name
[IN] key : key name
[IN/OUT] val_key : buffer holding the default key value in ASCII [IN] or/and the key value [OUT]
Return 0 : Key could not be retrieved (filename, section or key not found)
1 : Key has been succesfully read.
Description Used to read a key value directly from a file without the need to create the key if not present (as previous function). Typically this is used to read a setting from a file.
Comments Pretty useful!
VAPI Version 1.04 or greater

Example: find a proprietary key in a LDV INI file
long hini, must_save ;
short angle = 90;
/* Default value */ char buffer[256] ; char *path_ldv, *language ; path_ldv = Vapi->CoGetLDVPath() ; /* Get LDV current path */ language = Vapi->CoGetCurrentLanguage() ; /* Get current language */ if ( path_ldv && language ) { sprintf( buffer, "%s\\%s\\MYLDV.INI", path_ldv, language ) ; hini = Vapi->InOpen( buffer ) ;
if ( hini >= 0 )
{
sprintf( buffer, "%d", angle ) ;
/* Setting default value */ must_save = Vapi->InGetOrSetKey( hini, "Parameters", "Angle", buffer ) ;
angle = atoi( buffer ) ;
/* Either angle will be set to 90 (default value), or value retrieved from INI file */ if ( must_save ) Vapi->InSaveAndClose( hini ) ; /* Save if key did not exist */ else Vapi->InClose( hini ) ; /* Else regular close */ } }

Chapitre précédentRetour au sommaireChapitre suivant

Documentation VISION (VAPI)

Last update : 19/05/18


INI INTERFACE