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 索引创建

    --格式 --CREATE [索引类型] INDEX 索引名称--ON 表名(列名)--WITH FILLFACTOR = 填充因子值0~100--GO ----------------------- ...

  2. 去掉list重复值

    /** * 去掉list重复值 */ public List<String> removeDuplicate(List<String> list) { HashSet<S ...

  3. SIFT算法详解(转)

    http://blog.csdn.net/zddblog/article/details/7521424 目录(?)[-] 尺度不变特征变换匹配算法详解 Scale Invariant Feature ...

  4. listview中item 有checkbox多选防止滑动 listview页面 出现checkbox错位问题

    checkbox点击切换背景 <CheckBox android:id="@+id/checkbox" android:layout_width="40dp&quo ...

  5. 终于有SpringMvc与Struts2的对比啦(转)

    本文转自:http://www.itsource.cn/web/news/5/20150318/370.html 目前企业中使用SpringMvc的比例已经远远超过Struts2,那么两者到底有什么区 ...

  6. mysql笔记03 查询性能优化

    查询性能优化 1. 为什么查询速度会慢? 1). 如果把查询看作是一个任务,那么它由一系列子任务组成,每个子任务都会消耗一定的时间.如果要优化查询,实际上要优化其子任务,要么消除其中一些子任务,要么减 ...

  7. ftp 终端命令

    近期使用 macbook,并与新买的路由器折腾, 先备着... http://blog.csdn.net/qinde025/article/details/7595102 ftp使用的内部命令如下(其 ...

  8. UnicodeDecodeError: ‘ascii’ codec can’t decode...: ordinal not in range(128 问题解决

    UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128 原 ...

  9. 为Docker容器配置固定IP

    当docker以桥接的方式启动容器时,容器内部的IP是经过DHCP获取的,例如:172.17.0.8/32,且每重启依次IP都会发生变动.某些特殊的情况下,需要容器内有自己固定的一个内部IP.我的实现 ...

  10. 给windows服务打包,并生成安装程序

    一. 添加新建项目-->安装部署-->安装项目 二.安装程序上-->右键视图-->文件系统-->应用程序文件夹-->右键-->添加项目输出 选择做好的wind ...