INF文件写入读出

这段代码展示了如何使用C#编写一个IniFile类,该类利用API函数WritePrivateProfileString和GetPrivateProfileString实现对INI文件的读写操作。 IniFile类包括构造函数、API函数声明以及读写方法,方便在C/S应用中读取和写入配置信息。
摘要由CSDN通过智能技术生成

 库文件

System.Runtime.InteropServices

 

项目

录音系统V3.0(C/S)

 

代码

    class IniFile
    {
        #region 运行变量定义
        public string m_strPath;     //INI文件名
        #endregion

        #region 构造函数及资源回收
        public IniFile(string INIPath)
        {
            m_strPath = INIPath;
        }
        #endregion

        #region API函数声明
        //声明读写INI文件的API函数
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string
            section, string key, string val, string filePath);

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
        #endregion

        #region 共有函数处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值