• 5057阅读
  • 0回复

【原创】C#中怎样许.ini文件 [复制链接]

上一主题 下一主题
离线XChinux
 

只看楼主 倒序阅读 楼主  发表于: 2005-07-29
using System.Runtime.InteropServices;
....................
  [DllImport("kernel32")]
          private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
.......................
          StringBuilder database = new StringBuilder(255);
          StringBuilder hostname = new StringBuilder(255);
          StringBuilder username = new StringBuilder(255);
          StringBuilder password = new StringBuilder(255);
          string FileName = "yourfile.ini";
          string section = "your section";
          GetPrivateProfileString(section, "database", "", database, 255, FileName);
          GetPrivateProfileString(section, "hostname", "", hostname, 255, FileName);
          GetPrivateProfileString(section, "username", "", username, 255, FileName);
          GetPrivateProfileString(section, "password", "", password, 255, FileName);
          strConnectionString = "Database=" + database.ToString()
                              + ";Data Source=" + hostname.ToString()
                              + ";User Id=" + username.ToString()
                              + ";Password=" + password.ToString();


发表时间: 2005-05-24 18:40 |
[ 此贴被XChinux在2005-08-02 21:55重新编辑 ]
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个