WritePrivateProfileString()】的更多相关文章

在我们写的程序当中,总有一些配置信息需要保存下来,以便完成程序的功能,最简单的办法就是将这些信息写入INI文件中,程序初始化时再读入.具体应用如下: 将信息写入.INI文件中 1.所用的WINAPI函数原型为: BOOL WritePrivateProfileString( LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName ); 其中各参数的意义 LPCTSTR lpAppName 是INI文件中…
WritePrivateProfileString(_T("Section1"),_T("Field1"),Field,savePath); 函数说明,这是在写*.ini文件时使用的函数,在写ini文件的时候,可以调用这个函数,而不用使用挺费劲的关于txt文件的读写. 第一个参数为当前ini文件中节的名字. 第二个参数是ini文件中的字段名:Field1=*** 第三个参数是要写入的字符串,假设Field=1234,写出来的效果应该是:Field1=1234 第四个…
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Lon…
WritePrivateProfileString 写配置文件 BOOL WINAPI WritePrivateProfileString( _In_ LPCTSTR lpAppName, _In_ LPCTSTR lpKeyName, _In_ LPCTSTR lpString, _In_ LPCTSTR lpFileName ); 参数: lpAppName: 要复制字符串的部分的名称.如果该部分不存在,则创建它.该部分的名称与大小写无关; 字符串可以是大写和小写字母的任意组合. lpKey…
配置文件中经常用到ini文件,在VC中其函数分别为: 写入.ini文件: BOOL WritePrivateProfileString( LPCTSTR lpAppName, // INI文件中的一个字段名[节名]可以有很多个节名 LPCTSTR lpKeyName, // lpAppName 下的一个键名,也就是里面具体的变量名 LPCTSTR lpString, // 键值,也就是数据 LPCTSTR lpFileName // INI文件的路径 ); 读取.ini文件: DWORD Get…
INI文件就是扩展名为“ini”的文件.在Windows系统中,INI文件是很多,最重要的就是“System.ini”.“System32.ini”和“Win.ini”.该文件主要存放用户所做的选择以及系统的各种参数.用户可以通过修改INI文件,来改变应用程序和系统的很多配置.但自从Windows 95的退出,在Windows系统中引入了注册表的概念,INI文件在Windows系统的地位就开始不断下滑,这是因为注册表的独特优点,使应用程序和系统都把许多参数和初始化信息放进了注册表中.但在某些场合…
转载: 1.https://blog.csdn.net/fengbingchun/article/details/6075716 2. 转自:http://hi.baidu.com/andywangcn/blog/item/10ba730f48160eeb37d122e9.html 配置文件中经常用到ini文件,在VC中其函数分别为: #include <Windows.h> //wince,WMobile.ppc不支持这几个函数 写入.ini文件:bool WritePrivateProfi…
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函数分别对ini文件进行读和写操作.包括:读取key的值.保存key的值.读取所有section.读取所有key.移除section.移除key等操作. 目录 1. ini文件介绍 2. 读取操作:包括读取key的值.读取所有section.读取所有key等操作. 3. 写入操作: 包括保存key的值…
1.创建文件夹 //using System.IO; Directory.CreateDirectory(%%1);   2.创建文件 //using System.IO; File.Create(%%1);   3.删除文件 //using System.IO; File.Delete(%%1);   4.删除文件夹 //using System.IO; Directory.Delete(%%1);   5.删除一个目录下所有的文件夹 //using System.IO; foreach (s…
所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之文件处理函数 API之打印函数 API之文本和字体函数 API之菜单函数 API之位图.图标和光栅运算函数 API之绘图函数 API之设备场景函数 API之硬件与系统函数 API之进程和线程函数 API之控件与消息函数 1. API之网络函数 WNetAddConnection 创建同一个网络资源的…
0  概述 软件开机自启动是比较常用的做法,设置方法也有好几种. 1  使用者模式 在"开始菜单"的所有程序中有个"启动"文件夹,可以将需要设置为开机启动的应用程序放在这个文件夹中.但是,这样做存在不足:"启动"文件夹路径在每台电脑有可能是不同的,没法做到一劳永逸. 同时,如果要禁止程序开机启动,可将"启动"文件夹中对应的程序文件移除,也可以"Win+R"输入"msconfig"进行手动…
最近项目用到ini文件,读取ini文件,方法如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.Specialized; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; namespace test{ /…
[DllImport("kernel32")]//加载dll private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); //StringBuilder 可以返回值?想 Delphi var? //自己封装一下 private static string ReadINI…
c# 利用动态库DllImport("kernel32")读写ini文件 自从读了设计模式,真的会改变一个程序员的习惯.我觉得嘛,经验也可以从一个人的习惯看得出来,看他的代码编写习惯能看出一个程序员的经验.说啥呢,为啥又会说说设计模式去了呢,好吧,咱是来讨论读写ini文件的. 为什么要来讨论读写ini文件呢,难道有数据库我们就不用读写文件了吗,什么数据都从数据库读取出来吗,有些东西是根据客户的习惯,就没必要去读取数据库了,或者说,比如你要做一个记住密码的功能,如果在web端,你还可以用…
  //登录        private void btn_Login_Click(object sender, EventArgs e)        {            //记住密码            if (cb_remember.Checked == true)            { //把用户名和密码写入到程序运行目录的xtflz.dll文件中                WriteIni("My Section", this.tb_UserName.Tex…
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace 读写ini文件 {     public class Ini     {         // 声明INI文件的写操作函数 WritePrivateProfileString() [System.Runtime.InteropServices.DllImport("kern…
自定义IniFile操作类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.IO; namespace Sisley { public class INIFileHepler { private string Default_IniFileName = "Config.in…
Kernel.cs using System; using System.Runtime.InteropServices; using System.Text; using HANDLE = System.IntPtr; using HWND = System.IntPtr; namespace Win32 { public struct OVERLAPPED { public int Internal; public int InternalHigh; public int offset; p…
配置文件的格式主要有ini.xml.config等,现在对这些格式的配置文件的操作(C#)进行简单说明. INI配置文件操作 调用系统函数GetPrivateProfileString()和WritePrivateProfileString()等 (1)导入库 [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string va…
软件安装的实质就是拷贝,对于简单的打包当然不需要考虑修改某(配置)文件.通过inno修改文件的目的在于把安装时相关信息写入文件中,提供其它应用的读取,而这些信息也只能在安装时才能确定,比如安装用户选择的安装目录,或者是通过自定义界面输入的端口号等信息.所以其它与安装无关的信息可以尽量不要使用inno来写入文件,这样只是在增加工作量. Inno修改文件内容的方式有很多.我自己总结的有以下三种方式:通过[INI]段来直接写入配置信息,调用外部程序来读写文件,使用内置读写文件函数来修改文件. 1.[I…
http://www.cnblogs.com/endv/p/6052511.html // ------------------------------------------------------------------ // CaptureTest.cs // Sample application to show the DirectX.Capture class library. // // History: // 2003-Jan-25 BL - created // // Copyr…
DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL导出的函数的必要调用信息.    DllImport属性应用于方法,要求最少要提供包含入口点的dll的名称.    DllImport的定义如下: [AttributeUsage(AttributeTargets.Method)] public class DllImportAttribute: System.Attribute { public DllImportA…
这两天在折腾给一个项目打安装包,第一次接触软件打包,用的Advanced Installer(以下简称AI),应该说如果安装过程没有特殊动作(常规动作指释放文件.写注册表.建快捷方式等)的话,倒挺傻瓜的,按照向导和界面操作就能打好一个包.但我的安装动作包括: - 提供一个ComboBox列出已安装打印机让用户选择 - 让用户填写一些初始参数并在安装完成后把这些参数写入安装目录中的指定ini和xml文件中 第一个需求就折腾了我大半天,难点在于动态填充ComboBox项,资料和文档不好找,又是E文,…
1.创建文件夹//using System.IO;Directory.CreateDirectory(%%1); 2.创建文件//using System.IO;File.Create(%%1); 3.删除文件//using System.IO;File.Delete(%%1); 4.删除文件夹//using System.IO;Directory.Delete(%%1); 5.删除一个目录下所有的文件夹//using System.IO;foreach (string dirStr in Di…
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("ke…
1.添加引用 using System.IO; using System.Runtime.InteropServices; 2.声明API函数 #region API函数声明 [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filepath); [DllImport("kerne…
英文不好不要紧,把API函数导入打字练习类软件,即是练习打字速度,提高编程效率:也能短时间记忆API. 坚持每天打一遍,约2小时,连续打两周,会对API有很好的记忆,此方法是结合英文学习方法!以下是Window API函数例表,大家可以试试效果特别好! AbnormalTermination AbortDoc AbortPath AbortPrinter AbortProc AbortSystemShutdown AccessNtmsLibraryDoor ActivateKeyboardLay…
/****************************************************************** * * ^_^ 恶猫 独门商标 挖哈哈 * * QQ:\>23559055 * * Site:\>http://emao.me * * ================================================================ * * 说明: * * 1.命名空间: Emao_CfgManager * 类名 : CfgMa…
此功能是记住用户的操作,在用户点击关闭时是真退出程序还是最小化到托盘,我们常见的PC客户端都有此功能,例如:IMO客户端.网易云音乐 我自己的项目中也要实现此功能,在此总结一下,最终效果: .h文件 #ifndef _CLOSEHINTDIALOG_H_ #define _CLOSEHINTDIALOG_H_ class CCloseHintDialog :public WindowImplBase { public: CCloseHintDialog(); ~CCloseHintDialog(…
在C#中对INI文件进行读写操作,在此要引入using System.Runtime.InteropServices; 命名空间,具体方法如下: #region 变量 private static readonly string strFilePath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "App.ini";//INI文件路径 #endregion #region 私有方法 /// <summary> /…