1. //读写INI
  2. public class GF_INI
  3. {
  4. [DllImport("kernel32")]
  5. private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
  6. [DllImport("kernel32")]
  7. private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
  8. [DllImport("kernel32.dll")]
  9. public static extern int Beep(int dwFreq, int dwDuration);
  10.  
  11. //读ini
  12. public static void iniFile_SetVal(string in_filename, string Section, string Key, string Value)
  13. {
  14. WritePrivateProfileString(Section, Key, Value, in_filename);
  15. }
  16.  
  17. //写INI
  18. public static string iniFile_GetVal(string in_filename, string Section, string Key)
  19. {
  20. StringBuilder temp = new StringBuilder(255);
  21. int i = GetPrivateProfileString(Section, Key, "", temp, 255, in_filename);
  22. if (i == 0)
  23. return "";
  24. else
  25. return temp.ToString();
  26. }
  27. }

C#读写本地ini的更多相关文章

  1. C# 读写本地配置文件

    1.在本地有一个如下配置文件 2.读写本地配置文件 3.对配置文件的内容进行操作

  2. asp.net 操作INI文件的读写,读写操作本地ini配置文件

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  3. QT 读写配置文件 .ini

    高端大气上档次!码住 读取配置文件: //根据目录寻找配置文件 QSettings* setting = new QSettings("configs/config.ini", Q ...

  4. C# 读本地INI文件方法

    [DllImport("kernel32")]//加载dll private static extern int GetPrivateProfileString(string se ...

  5. 利用Lua读写本地文件

    缘由 今天在使用Lua编写脚本时,需要用到读写文件的操作,很久没有使用Lua了,特写下此文来备忘一下. 简介 Lua对文件的操作与C对文件的操作基本一致,不管是参数还是方法.Lua中可以直接通过全局方 ...

  6. Flutter 读写本地文件

    文档 注意 安装 path_provider 插件后重启f5, 而不是等待热更新 demo import 'dart:io'; import 'dart:async'; import 'package ...

  7. MFC读写配置ini文件

    https://blog.csdn.net/naibozhuan3744/article/details/78783446 https://blog.csdn.net/rayborn1105/arti ...

  8. java读写本地xml

    <?xml version="1.0" encoding="UTF-8" standalone="no"?> <confi ...

  9. node读写本地文件

    http://nodejs.cn/api/fs.html#fs_fs_writefilesync_file_data_options https://www.cnblogs.com/diaosizha ...

随机推荐

  1. sql 中实现打乱数据的排序

    sql 中实现打乱数据的排序    order by NEWID()就实现了数据的打乱 

  2. oracle的簇的管理

    使用ALTER修改簇属性(必须拥有ALTER ANY CLUSTER的权限) 1.修改簇属性 可以修改的簇属性包括: * PCTFREE.PCTUSED.INITRANS.MAXTRANS.STORA ...

  3. css 文字换行控制

    强制不换行 white-space:nowrap 强制不换行,并显示省略号 word-wrap: normal; text-overflow: ellipsis; white-space: nowra ...

  4. (第九周)视频发布及git统计报告

    项目名:食物链教学工具 组名:奋斗吧兄弟 组长:黄兴 组员:李俞寰.杜桥.栾骄阳.王东涵 代码地址:HTTPS: https://git.coding.net/li_yuhuan/FoodChain. ...

  5. 有图有真相——关于“视频专辑:零基础学习C语言 ”

  6. 关于MyEcplise中常见的问题和解决方案

    1.问题:严重   The web application  created a ThreadLocal with key of type  and a value of type  but fail ...

  7. Android 带checkbox的listView 实现多选,全选,反选

    由于listview的一些特性,刚开始写这种需求的功能的时候都会碰到一些问题,重点就是存储每个checkbox的状态值,在这里分享出了完美解决方法:     布局文件: [html]   <?x ...

  8. python时间处理函数

    所有日期.时间的api都在datetime模块内. 1. 日期输出格式化 datetime => string import datetime now = datetime.datetime.n ...

  9. linux下用core和gdb查询出现"段错误"的地方【转】

    转自:http://blog.chinaunix.net/uid-30091091-id-5754288.html 原文地址:linux下用core和gdb查询出现"段错误"的地方 ...

  10. oracle sqlloader 用法

    向oracle中导入*.csv文件   1.什么是*.csv,如何得到? 里面存放的是数据表.每行代表数据库表格的一行, 每行中,每两个数据中间由逗号","分割. *.csv可以通 ...