C# 读写 ini 配置文件
/// <summary>
/// 调用系统API 读写 ini 配置文件
/// </summary>
public class RWini
{
#region ========ini 读写======== // 声明INI文件的写操作函数 WritePrivateProfileString()
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); // 声明INI文件的读操作函数 GetPrivateProfileString()
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, System.Text.StringBuilder retVal, int size, string filePath); public static void WriteIni(string section, string key, string value,string path)
{
// section=配置节,key=键名,value=键值,path=路径
WritePrivateProfileString(section, key, value, path);
} public static string ReadIni(string section, string key,string path)
{
// 每次从ini中读取多少字节
System.Text.StringBuilder temp = new System.Text.StringBuilder();
// section=配置节,key=键名,temp=上面,path=路径
GetPrivateProfileString(section, key, "", temp, , path);
return temp.ToString();
} #endregion
}
C# 读写 ini 配置文件的更多相关文章
- [转]VB 读写ini 配置文件
转自 百度知道 C# 读写 ini配置文件 点此链接 'API 声明Public Declare Function GetPrivateProfileString Lib "kernel32 ...
- 自己写的 读写 ini 配置文件类
/// <summary> /// 不调用系统API 读写 ini 配置文件 /// </summary> public class RW_ini { #region ==== ...
- 引用“kernel32”读写ini配置文件
引用"kernel32"读写ini配置文件 unity ini kernel32 配置文件 引用"kernel32"读写ini配置文件 OverView ke ...
- C# 文件的一些基本操作(转)//用C#读写ini配置文件
C# 文件的一些基本操作 2009-07-19 来自:博客园 字体大小:[大 中 小] 摘要:介绍C#对文件的一些基本操作,读写等. using System;using System.IO;us ...
- C#操作读写INI配置文件
一个完整的INI文件格式由节(section).键(key).值(value)组成.示例如:[section]key1=value1key2=value2; 备注:value的值不要太长,理论上最多不 ...
- c#读写ini配置文件示例
虽然c#里都是添加app.config 并且访问也很方便 ,有时候还是不习惯用他.那么我们来做个仿C++下的那种ini配置文件读写吧 其他人写的都是调用非托管kernel32.dll.我也用过 ...
- WritePrivateProfileString等读写.ini配置文件
配置文件中经常用到ini文件,在VC中其函数分别为: 写入.ini文件: BOOL WritePrivateProfileString( LPCTSTR lpAppName, // INI文件中的一个 ...
- C++读写ini配置文件GetPrivateProfileString()&WritePrivateProfileString()
转载: 1.https://blog.csdn.net/fengbingchun/article/details/6075716 2. 转自:http://hi.baidu.com/andywangc ...
- QT读写ini配置文件
/********下面是写ini文件*************************/ //Qt中使用QSettings类读写ini文件 //QSettings构造函数的第一 ...
随机推荐
- @PropertySouce注解
1.@ProtertySource @PropertySouce是spring3.1开始引入的基于java config的注解. 通过@PropertySource注解将properties配置文件中 ...
- 使用C语言简单模拟Linux的cat程序
先给出源码 //fileio.c #include<stdio.h> #include<stdlib.h> #include<fcntl.h> void print ...
- Android USB Host框架
Android 下的usb框架及功能点:https://blog.csdn.net/tianruxishui/article/details/379029591.Android framework中* ...
- auto_ptr & share_ptr & unique_ptr
Using auto_ptr, you don’t need think about the memory deallocation, but there are also many argument ...
- Thread与ThreadPool的内存之战
Thread与ThreadPool使用的时候在内存里对象是如何分布的呢? 今天我们就从内存堆的角度分析下两者. 先上小白鼠代码: static void Main(string[] args) ...
- str_replace中的匹配空白符,必须用双引号
例: $minUnit = str_replace(array('\r','\n'),"",$content); 执行上面的语句,你会发现,文本没有任何变化,该换行的地方还是换行. ...
- vue项目权限控制
Vue权限控制有各种方法,大概分为两个方向: 把当前角色对应的权限保存在浏览器本地(容易被恶意修改): 将操作权限保存在vuex中(推荐此种方式:页面一刷新就没了,可以再次向后端请求相关数据,始终保持 ...
- linux shell获取键盘输入
linux shell从键盘获取输入 代码1: #!/bin/bash #提示“Input your choice:”,把用户的输入保存入变量choice_user中read -p "Inp ...
- 【转】Linux安装HDF5及遇到的问题总结
Linux安装HDF5及遇到的问题总结 转自: http://www.linuxdiyf.com/linux/26164.html ubuntu版本:16.04.2 64位 从HDF官网(http ...
- 基于redis的乐观锁实践
redis真是一个分布式应用场景下的好东西,对于我们的应用设计,功劳大大的! 今天要研究的是基于redis的事务机制以及watch指令(CAS)实现乐观锁的过程. 所谓乐观锁,就是利用版本号比较机制, ...