I try to get the INI file's value form. INI is the file:
[database] user = root pssword = lalalala server = localhostname = traveler and my code process for reading is: < / P> Joinfile (); Var ini file: TIniFile; User: string; Start {Abro el archivo ini} iniFile: = TIniFile.Create ('config.ini'); User: = iniFile.ReadString ('database', 'user', 'algo andy mal ...'); IniFile.Free; WriteLn (user); End; The Cli program that says the process:
WriteLn ('base database for the al utility': '); TestManejoIniFile (); ReadLn; CLI always gives:
Elioreo Para Lite Day data: Algo andy mail ... TIniFile? Create should look for the config.ini file, so by default it is looking in the Windows directory and not looking for it, and returned the default value that you said Should return it. You must specify the location of the config.ini file. If it is in the same folder as your application, you can use ParamStr (0) or Application.ExeName to ExtractFilePath . (I've added to end exceptions ... to the end , and moved to WriteLn so that it only if ReadString succeeds): Process testing manualonefile (); Var ini file: TIniFile; User: string; Path: string; Starting {path in Abrow L archive}: = Extract file path (Paramatt (0)); // or Application.ExeName iniFile: = TIniFile.Create (path + 'config.ini'); Try the user: = iniFile.ReadString ('database', 'user', 'algo andy mal ...'); WriteLn (user); Finally iniFile.Free; End; End;
No comments:
Post a Comment