Config.ini 文件操作

[SYS]

sysname=hy

company=hyhy

tel=2

using System;
using System.Collections.Generic;
using System.Text; namespace Common
{
public class SetINI
{
// 声明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); private string sPath = null;
public SetINI(string path)
{
this.sPath = path;
} public void Writue(string section, string key, string value)
{
// section=配置节,key=键名,value=键值,path=路径
WritePrivateProfileString(section, key, value, sPath);
}
public string ReadValue(string section, string key)
{
// 每次从ini中读取多少字节
System.Text.StringBuilder temp = new System.Text.StringBuilder(); // section=配置节,key=键名,temp=上面,path=路径
GetPrivateProfileString(section, key, "", temp, , sPath); return temp.ToString();
}
}
}
/*
string sCompany = "";
string Current = Directory.GetCurrentDirectory();//获取当前根目录 SetINI ini = new SetINI(Current + "/config.ini");
sCompany = ini.ReadValue("SYS", "company");
*/
//写入
/*
ini .Writue("SYS", "company", companyValue);
*/

ini文件操作的更多相关文章

  1. ini 文件操作记要(1): 使用 TIniFile

    ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Class ...

  2. winform INI文件操作辅助类

    using System;using System.Runtime.InteropServices;using System.Text; namespace connectCMCC.Utils{ // ...

  3. Ini文件操作类

    /// <summary> /// Ini文件操作类 /// </summary> public class Ini { // 声明INI文件的写操作函数 WritePriva ...

  4. C# ini文件操作【源码下载】

    介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...

  5. C#读写ini文件操作

    ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...

  6. C# Ini文件操作

    在开源中国看到的操作ini文件的,写的还不看,留着以后用 using System; using System.IO; using System.Runtime.InteropServices; us ...

  7. 读写INI文件操作类

    详情介绍:http://zh.wikipedia.org/wiki/INI%E6%96%87%E4%BB%B6 示例: 下面是一个虚拟的程序,其INI文件有两个小节,前面的小节是用来设置拥有者的信息, ...

  8. python基础——15(加密、excel操作、ini文件操作、xml操作模块及数据格式分类)

    一.加密模块 1.有解密的加密方式(base64) #base64加密 import base64 str_encrypt = input("输入要加密的字符串:\n") base ...

  9. Delphi ini文件操作 TIniFile、TMemIniFile

    1.使用TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...

随机推荐

  1. Linux DHCP通过OPTION43为H3C的AP下发AC地址

    对于DHCP服务,可以在很多平台上进行设置.那么这里我们就主要讲解一下在Linux DHCP服务器上通过option 43实现H3C的AP自动联系AC注册的相关内容.原来的DHCP Server是放在 ...

  2. JZOJ P1830[9.30]送牛奶

    传送门 临近NOIp,写一些简单题. 二分+BFS,注意的是要把数组开小点,有效减少memset的时间. //OJ 1830 //by Cydiater //2016.9.22 #include &l ...

  3. BZOJ2827: 千山鸟飞绝

    离散化坐标,每个坐标开一棵以鸟的编号为关键字的平衡树.每次插入时打2个标记,同时更新自身.这个方法比较显然,而且好写.正解好像用很迷的方法乱搞了一波,然后用线段树不打标记就做出来了,并不会. trea ...

  4. SQLServer------解决IP地址登录不了数据库问题

    1.找到配置管理器,打开 2.关掉SQLExpress,打开MSSQLServer 3.配置MSSQLServer(启用Named Pipes和TCP/IP) 4.修改TCP/IP属性(端口:1433 ...

  5. easyui numberbox一些常用属性,方法

    1.value="1234567.89"//数字框中的值 2.precision:2//精度(小数点后两位) 3.groupSeparator:','//(组分隔符) 4.deci ...

  6. js字符串RTrim方法(right trim)

    String.prototype.RTrim = function (c) { if (!c) { c = ' '; } var reg = new RegExp('([' + c + ']*$)', ...

  7. jquery id选择器 id带"."问题

    例如控件ID为user.id 使用$("#user.id")不能得到正确的结果 必须使用\\转义 即$("#user\\.id")

  8. Java关键字——throws和throw

    throws关键字 在定义一个方法时,可以使用throws关键字声明,使用throws声明的方法表示此方法不处理异常,而交给方法的调用处进行处理. 使用了throws关键字,表示不管是否会有异常,在调 ...

  9. ansible定时任务

    不得不说,ansible很强大,ansible定制任务模块显示 ansible all -m cron -a 'name="ban IP of login" minute=* ho ...

  10. 个人js

    1.网页右侧地图浮动楼层,超过100px就显示 $(window).scroll(function(){ ){ //距顶部多少像素时,出现返回顶部按钮 $("#floor").fa ...