五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

C#上位機(jī)對配置文件的操作演示

2023-07-22 09:29 作者:donet工控少俠  | 我要投稿

??public class IniConfigHelper

??{

????public static string filePath = "";


????#region API函數(shù)聲明


????[DllImport("kernel32")]

????private static extern long WritePrivateProfileString(string section, string key,

??????string val, string filePath);


????//需要調(diào)用GetPrivateProfileString的重載

????[DllImport("kernel32", EntryPoint = "GetPrivateProfileString")]

????private static extern long GetPrivateProfileString(string section, string key,

??????string def, StringBuilder retVal, int size, string filePath);


????[DllImport("kernel32", EntryPoint = "GetPrivateProfileString")]

????private static extern uint GetPrivateProfileStringA(string section, string key,

??????string def, Byte[] retVal, int size, string filePath);


????#endregion


????#region 獲取所有的Sections

????/// <summary>

????/// 獲取所有的Sections

????/// </summary>

????/// <param name="iniFilename">文件路徑</param>

????/// <returns>Sections集合</returns>

????public static List<string> ReadSections(string iniFilename)

????{

??????List<string> result = new List<string>();

??????Byte[] buf = new Byte[65536];

??????uint len = GetPrivateProfileStringA(null, null, null, buf, buf.Length, iniFilename);

??????int j = 0;

??????for (int i = 0; i < len; i++)

????????if (buf[i] == 0)

????????{

??????????result.Add(Encoding.Default.GetString(buf, j, i - j));

??????????j = i + 1;

????????}

??????return result;

????}


????#endregion


????#region 獲取指定Section下的所有Keys

????/// <summary>

????/// 獲取指定Section下的所有Keys

????/// </summary>

????/// <param name="SectionName">SectionName</param>

????/// <param name="iniFilename">文件路徑</param>

????/// <returns>Keys集合</returns>

????public static List<string> ReadKeys(string SectionName, string iniFilename)

????{

??????List<string> result = new List<string>();

??????Byte[] buf = new Byte[65536];

??????uint len = GetPrivateProfileStringA(SectionName, null, null, buf, buf.Length, iniFilename);

??????int j = 0;

??????for (int i = 0; i < len; i++)

????????if (buf[i] == 0)

????????{

??????????result.Add(Encoding.Default.GetString(buf, j, i - j));

??????????j = i + 1;

????????}

??????return result;

????}


????#endregion


????#region 讀Ini文件


????public static string ReadIniData(string Section, string Key, string NoText)

????{

??????return ReadIniData(Section, Key, NoText, filePath);

????}

????public static string ReadIniData(string Section, string Key, string NoText, string iniFilePath)

????{

??????if (File.Exists(iniFilePath))

??????{

????????StringBuilder temp = new StringBuilder(1024);

????????GetPrivateProfileString(Section, Key, NoText, temp, 1024, iniFilePath);

????????return temp.ToString();

??????}

??????else return String.Empty;

????}


????#endregion


????#region 寫Ini文件


????public static bool WriteIniData(string Section, string Key, string Value)

????{

??????return WriteIniData(Section, Key, Value, filePath);

????}


????public static bool WriteIniData(string Section, string Key, string Value, string iniFilePath)

????{

??????if (File.Exists(iniFilePath))

??????{

????????long OpStation = WritePrivateProfileString(Section, Key, Value, iniFilePath);

????????if (OpStation == 0)

??????????return false;

????????else return true;

??????}

??????else return false;

????}

????#endregion

??}

C#上位機(jī)對配置文件的操作演示的評論 (共 條)

分享到微博請遵守國家法律
鲁山县| 龙胜| 霞浦县| 碌曲县| 三台县| 南通市| 民丰县| 茌平县| 乌苏市| 屏南县| 滨州市| 通山县| 葵青区| 全南县| 两当县| 湟源县| 泾川县| 扎赉特旗| 文昌市| 定西市| 武宁县| 内江市| 阿勒泰市| 葫芦岛市| 嘉祥县| 东莞市| 错那县| 克拉玛依市| 纳雍县| 彭阳县| 满城县| 化德县| 灯塔市| 嘉兴市| 资溪县| 石狮市| 汶上县| 淳安县| 北安市| 连南| 太谷县|