VC程序读取配置文件内容
2013-01-18 23:10
399 查看
// 读取配置文件,获得链接数据库字符
CString Provi= _T("");
CString Security= _T("");
CString Persist= _T("");
CString Catalog= _T("");
CString Source= _T("");
::GetPrivateProfileString("Server","Provider","",
Provi.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Provi.ReleaseBuffer();
::GetPrivateProfileString("Server","Integrated Security","",
Security.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Security.ReleaseBuffer();
::GetPrivateProfileString("Server","Persist Security Info","",
Persist.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Persist.ReleaseBuffer();
::GetPrivateProfileString("Server","Initial Catalog","",
Catalog.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Catalog.ReleaseBuffer();
::GetPrivateProfileString("Server","Data Source","",
Source.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Source.ReleaseBuffer();
//连接成字符串
CString strConnectTmp="Provider="+Provi+";Integrated Security="+Security+";Persist Security Info="+Persist+";Initial Catalog="+Catalog+";Data Source="+Source;
配置文件格式
[Server]
Provider=SQLOLEDB.1
Integrated Security=SSPI
Persist Security Info=False
Initial Catalog=bookbase
Data Source=PETE-PC
[/Server]
CString Provi= _T("");
CString Security= _T("");
CString Persist= _T("");
CString Catalog= _T("");
CString Source= _T("");
::GetPrivateProfileString("Server","Provider","",
Provi.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Provi.ReleaseBuffer();
::GetPrivateProfileString("Server","Integrated Security","",
Security.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Security.ReleaseBuffer();
::GetPrivateProfileString("Server","Persist Security Info","",
Persist.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Persist.ReleaseBuffer();
::GetPrivateProfileString("Server","Initial Catalog","",
Catalog.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Catalog.ReleaseBuffer();
::GetPrivateProfileString("Server","Data Source","",
Source.GetBuffer(MAX_PATH), MAX_PATH,".\\databaselink.ini");
Source.ReleaseBuffer();
//连接成字符串
CString strConnectTmp="Provider="+Provi+";Integrated Security="+Security+";Persist Security Info="+Persist+";Initial Catalog="+Catalog+";Data Source="+Source;
配置文件格式
[Server]
Provider=SQLOLEDB.1
Integrated Security=SSPI
Persist Security Info=False
Initial Catalog=bookbase
Data Source=PETE-PC
[/Server]
相关文章推荐
- 使用程序来读取xml配置文件的内容
- myeclipse写配置文件,在程序里找到路径,并读取配置文件的内容
- winform程序读取和改写配置文件App.config元素的值
- 实现快速读写配置文件的内容,可以用于读取*.exe.config文件或者Web.Config文件的内容,或者可以读取指定文件的配置项.
- C语言编写读取配置文件程序
- vc2008: 控制台程序将数据写入MySql(数据库信息从配置文件读取)
- vb.net程序直接读取Excel文件内容
- [VC++]配置文件读取
- 配置文件读取内容,进行完整性检查
- IIS7.5配置Asp.net项目出现HTTP 错误 404.17 - Not Found 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。
- 读取【程序名称.exe.config】配置文件
- 读取INI配置文件内容(头文件head)
- Spring placeHolder读取文件内容注入参数配置
- 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理解决方案 服务器配置错误
- resin-admin.xml文件内容,这个管理程序用的是php,因此可以看看php程序的配置。
- java程序读取properties配置文件出现中文乱码
- c++ 读取整个文件内容 || VC 检查创建文件夹
- 读取配置文件的内容代码
- 读取INI配置文件内容(源文件C)
- 如何在jsp中读取配置文件的内容