section

C#读写ini文件详解

落爺英雄遲暮 提交于 2019-11-29 22:06:46
C#读写ini文件详解 C#读写ini文件是如何进行的呢?C#读写ini文件需要的方法有哪些呢?本文就向你一一介绍。 C#读写ini文件之前要了解的概念:INI就是扩展名为"INI"的文件,其实他本身是个文本文件,可以用记事本打开,主要存放的是用户所做的选择或系统的各种参数. C#读写ini文件其实并不是普通的文本文件.它有自己的结构.由若干段落(SECTION)组成,在每个带括号的标题下面,是若干个以单个单词开头的关键字(KEYWORD)和一个等号,等号右边就是关键字的值(VALUE).例如: [Section1] KeyWord1 = Value1 KeyWord2 = Value2 ... [Section2] KeyWord3 = Value3 KeyWord4 = Value4 C#读写ini文件最初的想法:C#命名空间中没有直接读写INI的类,当然如果你把INT当成文本文件用System.IO类来读写算我没说. 我现在介绍的是系统处理INI的方法. 虽然C#中没有,但是在"kernel32.dll"这个文件中有Win32的API函数--WritePrivateProfileString()和GetPrivateProfileString() C#读写ini文件实现之C#声明INI文件的写操作函数WritePrivateProfileString():

C# ini文件读写类

萝らか妹 提交于 2019-11-29 22:06:21
VC中提供了API函数进行INI文件的读写操作,但是微软推出的C#编程语言中却没有相应的方法,下面是一个C# ini文件读写类, 从网上收集的,很全,就是没有对section的改名功能,高手可以增加一个。 using System; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Collections; using System.Collections.Specialized; namespace wuyisky{   /**//**/   /**//// <summary>   /// IniFiles的类   /// </summary>   public class IniFiles   {     public string FileName; //INI文件名     //声明读写INI文件的API函数     [DllImport("kernel32")]     private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath);     [DllImport("kernel32")]    

C# 读写Ini文件,全代码示例解析

给你一囗甜甜゛ 提交于 2019-11-29 22:05:35
ini文件在Win95以前比较盛行,之后由于出册表等技术的出现,ini技术主键退居二线,不过对于一些小项目,读写ini文件还是很适用的。 Windows API提供了读写配置文件的操作,在C#程序中只要导入相应的API即可。例如GetPrivateProfileString()方法,在MSDN查得原型如下: DWORD GetPrivateProfileString( LPCTSTR lpAppName, // section name LPCTSTR lpKeyName, // key name LPCTSTR lpDefault, // default string LPTSTR lpReturnedString, // destination buffer DWORD nSize, // size of destination buffer LPCTSTR lpFileName // initialization file name ); 由于C#和C++数据类型不同,在导入win32 API时需要做相应的转换,并且要导入相关的类。如下所示: [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string defVal,

C# ini文件读写 类

筅森魡賤 提交于 2019-11-29 22:04:50
一个C# ini文件读写类,从网上收集的,很全,就是没有对section的改名功能,高手可以增加一个 using System; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Collections; using System.Collections.Specialized; namespace wuyisky { /**/ /// <summary> /// IniFiles的类 /// </summary> public class IniFiles { public string FileName; // INI文件名 // 声明读写INI文件的API函数 [DllImport("kernel32")] private static extern bool WritePrivateProfileString( string section, string key, string val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString( string section, string key, string def,

python读取配置文件中的信息

喜夏-厌秋 提交于 2019-11-29 04:43:10
一、ConfigParser模块简介 假设有如下配置文件,需要在Pyhton程序中读取 config.ini [db] db_port = 3306 db_user = root db_host = 127.0.0.1 db_pass = 123456789    如何读取呢 方法一: cp = configparser.ConfigParser()cp.read("conf.ini")print(cp.sections()) print(cp.options("db"))print(cp.get("db","db_user")) 运行结果: ['db'] ['db_port', 'db_user', 'db_host', 'db_pass'] root    方法二: import configparser cp = configparser.ConfigParser(allow_no_value=True) cp.read("conf.ini") data = cp.items("db") print(data) 运行结果: [('db_port', '3306'), ('db_user', 'root'), ('db_host', '127.0.0.1'), ('db_pass', '123456789')]    二、ConfigParser模块的常用方法 read

系统内存和进程内存

走远了吗. 提交于 2019-11-29 00:41:01
===系统内存=== 系统内存的使用情况可以用以下公式表示: MemTotal = MemFree +【Slab+ VmallocUsed + PageTables + KernelStack + HardwareCorrupted + Bounce + X】+【Active + Inactive + Unevictable + (HugePages_Total * Hugepagesize)】 MemTotal = MemFree +【Slab+ VmallocUsed + PageTables + KernelStack + HardwareCorrupted + Bounce + X】+【Cached + AnonPages + Buffers + (HugePages_Total * Hugepagesize)】 MemTotal = MemFree +【Slab+ VmallocUsed + PageTables + KernelStack + HardwareCorrupted + Bounce + X】+【ΣPss + (Cached – mapped) + Buffers + (HugePages_Total * Hugepagesize)】 File-backed内存,anon匿名内存,Shmem是tmpfs所使用的内存

《HTML5经典实例》读书笔记一

送分小仙女□ 提交于 2019-11-28 17:29:36
前言 什么是HTML5:HTML5是由W3C开发的一个规范——– http://dev.w3.org/html5/spec/ 第一章:基本语法和语义 问题:想要创建一个HTML5页面 在页面的最开始处指定HTML5 DOCTYPE: <!DOCTYPE html> //DOCTYPE不区分大小写 < html > ... </ html > DOCTYPE文档类型声明,告诉浏览器和验证器,该页面是使用哪个HTML的版本编写的。从HTML5开始,DOCTYPE中删除了版本号。这允许HTML5在语法方面可以向后兼容,从而有望使得向HTML5转换更容易。 问题:需要确定Web页面的字符编码。 在文档头部,为字符集添加meta声明: < meta charset = "UTF-8" > //HTML5将浏览器所需的信息最小 化,以前版本需要写成 < meta http-equiv = "Content-Type" content = "text/html" ;charset=UTF-8" /> 如果没有在HTML中声明字符集,浏览器首先尝试从服务器的HTTP响应头部(特别是”Content-Type”)来确认字符集。在响应头部中声明的字符集,通常要优先于在文档中指定的字符集,并且因此而成为优先使用的方法。如果不能控制服务器所发送的头部,则在HTML文档中声明字符集是次优的选择。

GCC __attribute__ 和 link 脚本控制 section 基地址

烂漫一生 提交于 2019-11-28 14:16:23
GCC __attribute__ 和 link 脚本控制 section 基地址 网上看的一篇文章,感谢作者,另外加上自己的一点注释。 ... ... ... ... .... .... ..... 利用 GCC 的 __attribute__ 属性的 section 选项来控制数据区的基地址。 以下例子,主要涉及到两个知识点,一个是 GNU C 扩展中的 attribute section 属性,关于这个知识点的相关信息可以参考: http://www.groad.net/bbs/read.php?tid=1035 另外一个知识点是 ld 连接器所用到的 link 脚本相关知识。 测试代码 : #include <stdio.h> int localmemory0 __attribute__ (( section ( "LOCALmem" ))) = 0 ; int localmemory1 __attribute__ (( section ( "LOCALmem" ))) = 0 ; int globalmemory __attribute__ (( section ( "GLOBALmem" ))) = 0 ; int main ( int argc , char * argv []) { localmemory0 = 0x456 ; localmemory1 =

编译静态库时,如何让编译器自动优化掉未使用的函数?

好久不见. 提交于 2019-11-28 14:10:56
-ffunction-sections 编译源文件时,为每个function分配独立的section。 -fdata-sections 编译源文件时,为每个data分配独立的section。 --gc-sections 链接时,以section为最小处理单元,只有当section中有symbol被使用,才将该section链接到output中。 来源: CSDN 作者: 乐不思猫的鼠 链接: https://blog.csdn.net/ernest68028/article/details/55094676

gcc的-ffunction-sections和-fdata-sections选项与ld的--gc-sections选项

点点圈 提交于 2019-11-28 14:09:40
-ffunction-sections, -fdata-sections会使compiler为每个function和data item分配独立的section。 --gc-sections会使ld删除没有被使用的section。 链接操作以section作为最小的处理单元,只要一个section中有某个符号被引用,该section就会被放入output中。 这些选项一起使用会从最终的输出文件中删除所有未被使用的function和data, 只包含用到的unction和data。 示例: C code: C代码 struct person { int age; int no; }; int plus_one( int no) { return no + 1; } int minus_one( int no) { return no - 1; } Run 'gcc -S -ffunction-sections -fdata-sections' produce: Assembly代码 .file "sec.c" .section .text.plus_one, "ax" ,@progbits .globl plus_one .type plus_one, @function plus_one: pushl %ebp movl %esp, %ebp movl 8 (%ebp), %eax