1
yangle
1 天以前 13441c4f01bcf12e56cd0ded30d6778eb585ee81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
 
namespace Pub_Class
{
    public class ClsIni
    {
 
        [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 fielPath);
 
        public static bool WriteIni(string section,string key, string keyvalue,string FileName)
        {
            WritePrivateProfileString(section, key, keyvalue, FileName);
            return true;
        }
 
        public static String ReadIni(string section, string key, string FileName)
        {
            StringBuilder def = new StringBuilder(255);
            int i;
            i = GetPrivateProfileString(section, key, "没有找到!", def, 255, FileName);
            return def.ToString();
        }
    }
}