1、获取应程序同极目录下的config.ini路劲

void GetConfigFilePath(char *path,int len, char *file)
{
char module[256] = {0};
GetModuleFileName(NULL, module, MAX_PATH);
char *ptr = strrchr(module, '\\');
int ptrsize = strlen(ptr);
int modulesize = strlen(module);
memset(path,0,len*sizeof(char));
memcpy(path,module,modulesize-ptrsize);
sprintf(path,"%s\\%s",path,file);
} 2、读取ini文件
int len = 0;
char m_configPath[1024] = {0};
char m_ParentIP_Char[256] = {0};
char m_ChileIP_Char[256] = {0};
char m_Port_Char[256] = {0};
char m_Peer_Port_Char[256] = {0};
char m_PeerID_Char[256] = {0};
char m_SubscriberID_Char[256] = {0}; GetConfigFilePath(m_configPath, len, "Config.ini");
::GetPrivateProfileString("OwnPeer", "ParentIP", "127.0.0.1", m_ParentIP_Char, 256, m_configPath);
::GetPrivateProfileString("OwnPeer", "ChileIP", "127.0.0.1", m_ChileIP_Char, 256, m_configPath);
::GetPrivateProfileString("OwnPeer", "Port", "50000", m_Port_Char, 256, m_configPath);\
::GetPrivateProfileString("OwnPeer", "PeerPort", "50010", m_Peer_Port_Char, 256, m_configPath);
::GetPrivateProfileString("OwnPeer", "PeerID", "131071", m_PeerID_Char, 256, m_configPath);
::GetPrivateProfileString("OwnPeer", "SubscriberID", "131071", m_SubscriberID_Char, 256, m_configPath);

  

VS VC 读取 INI文件的更多相关文章

  1. C#读取ini文件的方法

    最近项目用到ini文件,读取ini文件,方法如下: using System; using System.Collections.Generic; using System.Linq; using S ...

  2. C# 读取ini文件,读不出来原因

    先赋上相关读取ini文件代码 public class INIHelper { public string inipath; [DllImport("kernel32")] pri ...

  3. C# 通过api函数GetPrivateProfileString读取ini文件,取不到值

    通过api函数GetPrivateProfileString读取ini文件,取不到值,测试了好长时间,都不行 确认程序,ini文件都没有错误的情况,最后发现是ini文件编码的原因. 将ini文件的编码 ...

  4. C# 读取ini文件 百度问问学习文档

    C# 读取ini文件 10 有多个section,现想读取整个ini文件和指定section下所有内容 补充: 发布答案可以,请对准题目啊,我不要指定节点的内容,我知道!我要的是读取指定区域的内容,假 ...

  5. python中configparser模块读取ini文件

    python中configparser模块读取ini文件 ConfigParser模块在python中用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(se ...

  6. bat 读取 ini 文件

    bat 读取 ini 文件 参考链接:https://stackoverflow.com/questions/2866117/windows-batch-script-to-read-an-ini-f ...

  7. java读取ini文件

    ini工具类; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import j ...

  8. Python基础之读取ini文件

    基本使用方法 第一步:准备一份INI文件.如test1.ini [ITEMS] item1=1 item2=2 item3=3 item4=4 [ITEM1] test1=aaa [ITEM2] te ...

  9. VC++ 实现INI文件读写操作

    转载:https://blog.csdn.net/fan380485838/article/details/73188420 在实际项目开发中,会用ini配置文件,在此总结一下对ini读写操作 一:读 ...

随机推荐

  1. [No0000C9]神秘的掐指一算是什么?教教你也会

    很多朋友看到传说中诸葛亮以及那些聪明人掐指一算,惊叹不已.那些人以“察天地之理.通鬼神之志”,每次占卜时,做一大堆的神秘仪式,然后掐指一算,便大有“乾坤尽收在手”的感觉.在普通人眼里,他们的手神秘异常 ...

  2. [No0000B9]C# 类型基础 值类型和引用类型 及其 对象复制 浅度复制vs深度复制 深入研究2

    接上[No0000B5]C# 类型基础 值类型和引用类型 及其 对象判等 深入研究1 对象复制 有的时候,创建一个对象可能会非常耗时,比如对象需要从远程数据库中获取数据来填充,又或者创建对象需要读取硬 ...

  3. [性能优化] perf 高级用法:完整记录程序性能指标,并按照时间段对程序进行有针对性的性能分析

    如题: 假设你已经熟悉了基本用法,知道perf是干嘛的,以及会用 perf top [性能优化] perf 背景:目标程序在运行的某时间段内会出现性能下降,需要了解这个时间内,程序发生了什么. 方法: ...

  4. Flink - FlinkKafkaProducer010

    https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/connectors/kafka.html 使用的方式, DataStr ...

  5. LeetCode 136 Single Number 解题报告

    题目要求 Given a non-empty array of integers, every element appears twice except for one. Find that sing ...

  6. Mybatis中dao接口和mapper 的加载过程

    这里考虑的是mybatis和spring整合的场景 1.在系统启动的时候,会去执行配置文件中有关扫描mybatis接口的配置:通过MapperScannerConfigurer扫描接口生成spring ...

  7. panda核心数据结构

    Series Series是一维带标签的数组,数组里可以放任意的数据(整数.浮点数.字符串.python Object)等等 创建函数: (1)s = pd.Series(data,index=ind ...

  8. zedboard上首个驱动实践——Led

    // led驱动 *myled.c*//头文件 #include<linux/module.h> //最基本的文件,支持动态添加和卸载模块 #include<linux/kernel ...

  9. vc让界面保持最上层

    vc让界面保持最上层.事实上就一个函数就ok了, ::SetWindowPos(AfxGetMainWnd()->m_hWnd,HWND_TOPMOST,-1,-1,-1,-1,0);

  10. SQL 2016 AlwaysOn 无域AlwaysOn配置要点

    环境准备: (1)操作系统:Windows Server 2016 Datacenter (2)SQL Server 2016 配置SQL  2016 AlwaysOn 要点 1,因为没有域所以需要在 ...