From e1839e50f5d571b0e2c822d066a03a285d3b65fa Mon Sep 17 00:00:00 2001 From: sc <2401809606@qq.com> Date: Tue, 23 Sep 2025 01:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 6 ++ App.xaml | 9 ++ App.xaml.cs | 17 ++++ IniFile.cs | 52 ++++++++++ MainWindow.xaml | 142 +++++++++++++++++++++++++++ MainWindow.xaml.cs | 163 +++++++++++++++++++++++++++++++ Properties/AssemblyInfo.cs | 52 ++++++++++ Properties/Resources.Designer.cs | 71 ++++++++++++++ Properties/Resources.resx | 117 ++++++++++++++++++++++ Properties/Settings.Designer.cs | 30 ++++++ Properties/Settings.settings | 7 ++ StatisticsUI.csproj | 105 ++++++++++++++++++++ StatisticsUI.ini | 7 ++ StatisticsUI.sln | 25 +++++ sunlight_logo.ico | Bin 0 -> 16958 bytes 15 files changed, 803 insertions(+) create mode 100644 App.config create mode 100644 App.xaml create mode 100644 App.xaml.cs create mode 100644 IniFile.cs create mode 100644 MainWindow.xaml create mode 100644 MainWindow.xaml.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 StatisticsUI.csproj create mode 100644 StatisticsUI.ini create mode 100644 StatisticsUI.sln create mode 100644 sunlight_logo.ico diff --git a/App.config b/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App.xaml b/App.xaml new file mode 100644 index 0000000..31d7333 --- /dev/null +++ b/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..3be5ab5 --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ProcessManagGUI +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + } +} diff --git a/IniFile.cs b/IniFile.cs new file mode 100644 index 0000000..536b47d --- /dev/null +++ b/IniFile.cs @@ -0,0 +1,52 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace StatisticsUI +{ + internal class IniFile + { + public class IniFiles + { + public string path; + [DllImport("kernel32")] //返回0表示失败,非0为成功 + private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); + [DllImport("kernel32")] //返回取得字符串缓冲区的长度 + private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); + /// + /// 保存ini文件的路径 + /// 调用示例:var ini = IniFiles("C:\file.ini"); + /// + /// + public IniFiles(string iniPath) + { + this.path = iniPath; + } + /// + /// 写Ini文件 + /// 调用示例:ini.IniWritevalue("Server","name","localhost"); + /// + /// [缓冲区] + /// 键 + /// 值 + public void IniWritevalue(string Section, string Key, string value) + { + WritePrivateProfileString(Section, Key, value, this.path); + } + /// + /// 读Ini文件 + /// 调用示例:ini.IniWritevalue("Server","name"); + /// + /// [缓冲区] + /// 键 + /// + public string IniReadvalue(string Section, string Key) + { + StringBuilder temp = new StringBuilder(255); + + int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); + return temp.ToString(); + } + + } + } +} diff --git a/MainWindow.xaml b/MainWindow.xaml new file mode 100644 index 0000000..99461f9 --- /dev/null +++ b/MainWindow.xaml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +