| 1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDFMonitor_SVG {
- internal class IniFile {
- private string filePath;
- [DllImport("kernel32", CharSet = CharSet.Unicode)]
- private static extern long WritePrivateProfileString(string section, string key, string value, string filePath);
- [DllImport("kernel32", CharSet = CharSet.Unicode)]
- private static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder retVal, int size, string filePath);
- public IniFile(string filePath) {
- this.filePath = filePath;
- }
- public string Read(string section, string key, string defaultValue = "") {
- var retVal = new StringBuilder(255);
- GetPrivateProfileString(section, key, defaultValue, retVal, 255, filePath);
- return retVal.ToString();
- }
- public void Write(string section, string key, string value) {
- WritePrivateProfileString(section, key, value, filePath);
- }
- }
- }
|