forked from kvakulo/Switcheroo
-
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.
use ini file to implement the predefined abbreviation
- Loading branch information
Showing
11 changed files
with
124 additions
and
67 deletions.
There are no files selected for viewing
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
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,51 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace Switcheroo.Core | ||
{ | ||
class IniFile // 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 IniFile(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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="ini-parser" version="2.5.2" targetFramework="net48" /> | ||
<package id="MSBuildTasks" version="1.4.0.65" targetFramework="net45" /> | ||
</packages> |