diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-11-18 16:29:54 +0000 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-11-18 16:29:54 +0000 |
| commit | 4037be53b29a122732cfc10693e9c0027f606bb0 (patch) | |
| tree | 8533ea9ee0ac8f5f7f696b85cb039f783657ada0 /ShiftOS.Engine/Misc/IniFile.cs | |
| parent | 65b7ac2b8cbc4478f6d31a21f106048aeb075078 (diff) | |
| parent | 97722fbe9d474adffbba0b92e9727c48a8205234 (diff) | |
| download | shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.tar.gz shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.tar.bz2 shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.zip | |
Updated my fork!
Conflicts:
ShiftOS.Engine/ShiftOS.Engine.csproj
ShiftOS.Engine/Terminal/Commands/Hello.cs
ShiftOS.Engine/Terminal/TerminalBackend.cs
ShiftOS.Engine/Terminal/TerminalCommand.cs
ShiftOS.Main/ShiftOS.Main.csproj
ShiftOS.Main/ShiftOS/Apps/Terminal.cs
ShiftOS.Main/ShiftOS/Desktop.cs
Diffstat (limited to 'ShiftOS.Engine/Misc/IniFile.cs')
| -rw-r--r-- | ShiftOS.Engine/Misc/IniFile.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ShiftOS.Engine/Misc/IniFile.cs b/ShiftOS.Engine/Misc/IniFile.cs new file mode 100644 index 0000000..e31583f --- /dev/null +++ b/ShiftOS.Engine/Misc/IniFile.cs @@ -0,0 +1,50 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace ShiftOS.Engine.Misc +{ + /// <summary> + /// Create a New INI file to store or load data + /// </summary> + public class IniFile + { + readonly string _path; + + public IniFile(string iniPath) => _path = iniPath; + + [DllImport("kernel32")] + static extern long WritePrivateProfileString( + string section, + string key, + string val, + string filePath); + + [DllImport("kernel32")] + static extern int GetPrivateProfileString( + string section, + string key, + string def, + StringBuilder retVal, + int size, + string filePath); + + public void WriteValue(string section, string key, string value) + { + WritePrivateProfileString(section, key, value, _path); + } + + public string ReadValue(string section, string key) + { + var temp = new StringBuilder(255); + GetPrivateProfileString( + section, + key, + "", + temp, + 255, + _path); + + return temp.ToString(); + } + } +}
\ No newline at end of file |
