ini文件动态配置程序参数
来源:互联网 发布:内蒙广电网络宽带登录 编辑:程序博客网 时间:2024/04/27 19:59
#include <windows.h>
#include <stdio.h>
#include <string.h>
#define WOM_WOMCLTMD_INI "E://work//vctest//testmjong//womcltmd.ini"
int main(void)
{
unsigned int func_rtn;
char StrBuf[256];
char work[256];
memset(StrBuf, '/0', sizeof(StrBuf));
memset(work, '/0', sizeof(work));
memcpy(work,"Can not fined",15);
func_rtn = GetPrivateProfileInt(
"womcltmd",
"daikou_second",
0,
WOM_WOMCLTMD_INI);
printf("func_rtn = %d/nwork = %s/nStrBuf = %s/n",func_rtn,work,StrBuf);
return 0;
}
需要注意的地方:
1. 要是全路径
2.可以通过GetCurrentDirectory()函数来配合使用,我上面只是提供一个例子来测试下,大家若是需要可以做修改。
3.另外大家如果要从配置文件中获得字符串,可以用这个函数GetPrivateProfileString
GetPrivateProfileString
The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.
Note This function is provided only for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry.
msdn上面的描述如果是32位的系统要把这些信息放在注册表中。
我尝试了下其实放在配置文件中依然可以读取正确。
- ini文件动态配置程序参数
- 【整理】eclipse.ini/myeclipse.ini文件中参数配置【zz】
- eclipse.ini/myeclipse.ini文件中参数配置
- eclipse.ini/myeclipse.ini文件中参数配置
- notes.ini文件的配置参数详解
- notes.ini文件的配置参数详解
- eclipse.ini参数配置
- 数据库的备份与还原+INI文件数据库参数配置
- 开发工具eclipse优化JVM参数eclipse.ini文件配置
- 【叫我小猫Frank|整理】eclipse.ini/myeclipse.ini文件中参数配置
- ini文件配置模块
- 读写配置ini文件
- php.ini配置参数说明
- notes.ini部分参数配置
- eclipse.ini配置jvm参数
- BOOT.INI文件参数介绍
- php.ini文件 open_basedir参数
- 创建INI文件读写程序
- 感动~~~~~~~~~
- 国内著名黑客介绍
- 福娃免费空间"并连接地址"http://h.8wa.com
- ASP.NET调用oracle存储过程的方法
- Struts-Spring-Hibernate 搭配使用
- ini文件动态配置程序参数
- java Reflection
- spring 事务配置方法
- 日记090816
- 我们是否要发明轮子?
- JavaMail项目总结
- title001
- C#读取Word表格中的数据 (转)
- title002