C#:Ini文件操作(待补充)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; namespace MyCommanHelper
{
/// <summary>
/// 操作ini配置文件
/// </summary>
public class INIHelper
{
// Methods
#region DLL导入函数
/// <summary>
/// 获取指定条目值
/// </summary>
/// <param name="section">小结</param>
/// <param name="key">条目</param>
/// <param name="def">默认返回值</param>
/// <param name="retVal">返回值缓冲区</param>
/// <param name="size">缓冲区的最大字符数量 </param>
/// <param name="filePath">查找文件路径、名字</param>
/// <returns></returns>
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
/// <summary>
/// 写入指定条目值
/// </summary>
/// <param name="section">小结</param>
/// <param name="key">条目</param>
/// <param name="val">写入的字串值</param>
/// <param name="filePath">初始化文件的路径、名字</param>
/// <returns></returns>
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); #endregion #region 方法
/// <summary>
/// 读条目值
/// </summary>
/// <param name="sIniPath">文件路径名</param>
/// <param name="Section">小结</param>
/// <param name="Key">条目</param>
/// <returns></returns>
public static string IniReadValue(string sIniPath, string Section, string Key)
{
StringBuilder retVal = new StringBuilder(0xff);
int num = GetPrivateProfileString(Section, Key, "", retVal, 0xff, sIniPath);
return retVal.ToString();
} /// <summary>
/// 写条目值
/// </summary>
/// <param name="sIniPath">文件路径名</param>
/// <param name="Section">小结</param>
/// <param name="Key">条目</param>
/// <param name="Value">写入字符串值</param>
public static void IniWriteValue(string sIniPath, string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, sIniPath);
} #endregion
}
}
C#:Ini文件操作(待补充)的更多相关文章
- ini文件操作
Config.ini 文件操作 [SYS] sysname=hy company=hyhy tel=2 using System; using System.Collections.Generic; ...
- ini 文件操作记要(1): 使用 TIniFile
ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Class ...
- winform INI文件操作辅助类
using System;using System.Runtime.InteropServices;using System.Text; namespace connectCMCC.Utils{ // ...
- Ini文件操作类
/// <summary> /// Ini文件操作类 /// </summary> public class Ini { // 声明INI文件的写操作函数 WritePriva ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- C#读写ini文件操作
ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...
- C# Ini文件操作
在开源中国看到的操作ini文件的,写的还不看,留着以后用 using System; using System.IO; using System.Runtime.InteropServices; us ...
- 读写INI文件操作类
详情介绍:http://zh.wikipedia.org/wiki/INI%E6%96%87%E4%BB%B6 示例: 下面是一个虚拟的程序,其INI文件有两个小节,前面的小节是用来设置拥有者的信息, ...
- python基础——15(加密、excel操作、ini文件操作、xml操作模块及数据格式分类)
一.加密模块 1.有解密的加密方式(base64) #base64加密 import base64 str_encrypt = input("输入要加密的字符串:\n") base ...
- Delphi ini文件操作 TIniFile、TMemIniFile
1.使用TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...
随机推荐
- Qt移动应用开发(八):实现跨平台的QML和OpenGL混合渲染
Qt移动应用开发(八):实现跨平台的QML和OpenGL混合渲染 上一篇文章讲到了利用C++这个桥梁,我们实现了QML和Java的交互.Qt 5大力推崇的QML/JS开发,让轻量.高速开发的QML/J ...
- Executing a system tool
Executing a system tool The following code example shows the execution of the Buffer tool from the A ...
- Shuttle ESB(四)——公布订阅模式实例介绍(1)
前面,我已经集中用了三篇文章来讲Shuttle ESB的入门实例与宏观概念. Shuttle ESB一共同拥有两种发送消息的模式:请求/对应模式与Pub/Sub模式. 关于这两种模式的区分.请看以下文 ...
- 第十五章 php时区报错 We selected the timezone 'UTC'
Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to ...
- [Android Studio] Android Studio如何提示函数用法
Eclipse有一个很好的功能,就是当你代码调用某个android API时,鼠标移到对应的函数或者方法上,就会自动有一个悬 浮窗提示该函数的说明(所包含的参数含义,该方法功能).迁移到Android ...
- SDUT2013级測试赛_D
题目描写叙述 给出一棵含有n个点的树.每一个点权值为wi.求从根节点到叶子结点权值和最大的那条路经的权值和是多少. 输入 n(1<= n && n <= 10000). 接 ...
- go语言基础之输入的使用
1.输入的使用 第一种写法:fmt.Scanf("%d", &a) 第二种写法:fmt.Scan(&a) 示例: package main //必须有一个main包 ...
- 服务器主机上RAID Card的Write Caching Policy
在Cisco Server的DRAC中, 创建virtual drive时, 会看到下面的选项. 那么Write back, write through, write back bad BBU之间 ...
- 使用CSS3建立不可选的的文字
下面的例子展示了在HTML5中你如何使用CSS建立不可选的文字. <!DOCTYPE HTML> <html> <head> <title>Creati ...
- IOS中WebView的使用
UIWebView是iOS sdk中一个最常用的控件.是内置的浏览器控件,我们可以用它来浏览网页.打开文档等等,UIWebView能够加载html/htm.pdf.docx.txt等格式的文件 系统 ...