This repository has been archived by the owner on Dec 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a570aba
commit 92a18c5
Showing
8 changed files
with
144 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MusicBeePlugin | ||
{ | ||
public class IniParser // revision 11 | ||
{ | ||
string Path; | ||
string EXE = Assembly.GetExecutingAssembly().GetName().Name; | ||
|
||
[DllImport("kernel32", CharSet = CharSet.Unicode)] | ||
static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath); | ||
|
||
[DllImport("kernel32", CharSet = CharSet.Unicode)] | ||
static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath); | ||
|
||
public IniParser(string IniPath = null) | ||
{ | ||
Path = new FileInfo(IniPath ?? EXE + ".ini").FullName; | ||
} | ||
|
||
public string Read(string Key, string Section = null) | ||
{ | ||
var RetVal = new StringBuilder(255); | ||
GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path); | ||
return RetVal.ToString(); | ||
} | ||
|
||
public void Write(string Key, string Value, string Section = null) | ||
{ | ||
WritePrivateProfileString(Section ?? EXE, Key, Value, Path); | ||
} | ||
|
||
public void DeleteKey(string Key, string Section = null) | ||
{ | ||
Write(Key, null, Section ?? EXE); | ||
} | ||
|
||
public void DeleteSection(string Section = null) | ||
{ | ||
Write(null, null, Section ?? EXE); | ||
} | ||
|
||
public bool KeyExists(string Key, string Section = null) | ||
{ | ||
return Read(Key, Section).Length > 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<?xml version="1.0"?> | ||
<configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration> |
Oops, something went wrong.