zoukankan      html  css  js  c++  java
  • .net操作InI文件

    public class INI
    {

     public static string IniFileName = "";//路径

    [DllImport("kernel32")]
    private static extern int GetPrivateProfileInt(string lpApplicationName, string lpKeyName, int nDefault, string lpFileName);
    [DllImport("kernel32")]
    private static extern bool GetPrivateProfileString(string lpApplicationName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
    [DllImport("kernel32")]
    private static extern bool WritePrivateProfileString(string lpApplicationName, string lpKeyName, string lpString, string lpFileName);
    [DllImport("kernel32")]
    private static extern bool GetPrivateProfileSection(string lpAppName, string lpReturnedString, int nSize, string lpFileName);
    [DllImport("kernel32")]
    private static extern bool WritePrivateProfileSection(string lpAppName, string lpString, string lpFileName);

    public void WriteValue(string Section,string Key,string Value)//对ini文件进行写操作的函数
    {
    WritePrivateProfileString(Section, Key, Value, IniFileName);
    }

    public string ReadValue(string Section, string Key)//对ini文件进行读操作的函数
    {
    StringBuilder temp = new StringBuilder(50000);
    bool b = GetPrivateProfileString(Section, Key, "", temp, temp.Capacity, IniFileName);
    return temp.ToString();
    }

    }

  • 相关阅读:
    Flex上传文件报“Error #2038”
    AMQ9558
    perl 运算符
    linux gdm 远程桌面访问
    perl 捕获变量
    android apk嵌套 从一个apk启动另外一个apk
    apk调用另一个apk
    ORA-01591 锁被未决分布式事务处理
    jQuery事件控制点击内容下拉
    作业还是作孽?——Leo鉴书79
  • 原文地址:https://www.cnblogs.com/huguole/p/6163637.html
Copyright © 2011-2022 走看看