From a10440a45c40652b13e883aec832a0c8ded685e8 Mon Sep 17 00:00:00 2001 From: John T Date: Sun, 5 Nov 2017 18:47:46 -0500 Subject: Added a half-complete ShiftFS and did some code cleanup --- ShiftOS.Engine/Misc/IniFile.cs | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 ShiftOS.Engine/Misc/IniFile.cs (limited to 'ShiftOS.Engine/Misc/IniFile.cs') 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 +{ + /// + /// Create a New INI file to store or load data + /// + 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 -- cgit v1.2.3