读取配置文件 C#

来源:互联网 发布:sql导入oracle数据库 编辑:程序博客网 时间:2024/05/16 06:49

函数声明:

       [DllImport("kernel32.dll", EntryPoint = "GetPrivateProfileString")]

      //[DllImport("kernel32.dll",SetLastError = true)]
        public static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault,StringBuilder lpReturnedString, int nSize, string lpFileName);

 

调用:           StringBuilder str = new StringBuilder();
            int i = SendMessage.GetPrivateProfileString("Student", "Name", "", str, 8, "F:\\test.ini");
            MessageBox.Show(i.ToString());
            MessageBox.Show(str.ToString());

 


[Student]
Name=Kent


原创粉丝点击