Registry vs. INI file for storing user configurable application settings [closed]

Pros of config file: Easy to do. Don’t need to know any Windows API calls. You just need to know the file I/O interface of your programming language. Portable. If you port your application to another OS, you don’t need to change your settings format. User-editable. The user can edit the config file outside of … Read more

browscap ini directive not set

I don’t think this is the “best” solution to detect is a browser supports what you need for your website : first of all, browsers can lie — they can send whatever thay want as User-Agent And even if a given version of a support should support what you need, Javascript can still be disabled. … Read more

How to read and write to an ini file with PHP

You can simply use parse_ini_file with PHP4/5. $ini_array = parse_ini_file(“sample.ini”); print_r($ini_array); Here is the doc: http://php.net/manual/en/function.parse-ini-file.php To write back an array of objects back to the ini file, use below as a very fast & easy solution: function write_php_ini($array, $file) { $res = array(); foreach($array as $key => $val) { if(is_array($val)) { $res[] = “[$key]”; … Read more

Function Get-IniContent is not recognized – INI file support inPowerShell

JeroenMostert has provided the crucial pointer in a comment: PowerShell, as of v7.2.x, has no built-in cmdlets for processing INI files (*.ini), though introducing such cmdlets is being discussed in GitHub issue #9035. Get-IniContent and Out-IniFile are advanced functions (cmdlet-like functions) that come with the third-party PSIni module, available from the PowerShell Gallery. In PowerShell … Read more

How to parse ini file with Boost

You can also use Boost.PropertyTree to read .ini files: #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ini_parser.hpp> … boost::property_tree::ptree pt; boost::property_tree::ini_parser::read_ini(“config.ini”, pt); std::cout << pt.get<std::string>(“Section1.Value1”) << std::endl; std::cout << pt.get<std::string>(“Section1.Value2”) << std::endl;

Windows batch script to read an .ini file

Here’s a command file (ini.cmd) you can use to extract the relevant values: @setlocal enableextensions enabledelayedexpansion @echo off set file=%~1 set area=[%~2] set key=%~3 set currarea= for /f “usebackq delims=” %%a in (“!file!”) do ( set ln=%%a if “x!ln:~0,1!”==”x[” ( set currarea=!ln! ) else ( for /f “tokens=1,2 delims==” %%b in (“!ln!”) do ( set … Read more

parsing .properties file in Python

Say you have, e.g.: $ cat my.props first: primo second: secondo third: terzo i.e. would be a .config format except that it’s missing a leading section name. Then, it easy to fake the section header: import ConfigParser class FakeSecHead(object): def __init__(self, fp): self.fp = fp self.sechead = ‘[asection]\n’ def readline(self): if self.sechead: try: return self.sechead … Read more

Cross-platform way to get line number of an INI file where given option was found

Once again, took the opportunity to play with Boost Spirit. This time I got to play with line_pos_iterator. Here is the fruit of my labour: https://gist.github.com/1425972 When POSITIONINFO == 0 input is streaming output is raw strings (well, map<string, map<string, string> > for the sections) When POSITIONINFO == 1 input is buffered output is textnode_t: … Read more