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. [No0000154]详解为什么32位系统只能用4G内存.

    既然是详解, 就从最基础的讲起了. 或者1来存储数据的, 所以Bit实际上可以看成存放1个二进制数字的1个位置.也就是说bit只有2种值, 0 或者 1, 所以1个bit能存放1个布尔类型的值(boo ...

  2. python数据结构之图论

    本篇学习笔记内容为图的各项性质.图的表示方法.图ADT的python实现 图(Graph) 是数据结构和算法学中最强大的框架之一(或许没有之一).图几乎可以用来表现所有类型的结构或系统,从交通网络到通 ...

  3. tst

    select count(*) from student where age>18 group by 性别 having count(*)>2 order by age where过滤的是 ...

  4. Appium入门(5)__ Appium测试用例(1)

    步骤为:启动AVD.启动Appium.写用例(python).执行 一.启动Android模拟器                   二.启动Appium Server 双击appium图标启动,配置 ...

  5. Python开发【笔记】:asyncio 定时器

    asyncio 定时器 实现: import asyncio class Timer: def __init__(self, timeout, callback): self._timeout = t ...

  6. pyqt5-对文本样式进行操作

    self.label_2 = QtWidgets.QLabel(self.centralWidget) self.label_2.setGeometry(QtCore.QRect(330, 220, ...

  7. 注解之@CookieValue

    @RequestHeader以及@CookieValue这两个注解用法类似,属性也相同,所以,写在一起.二者属性和RequestParam的属性一样,用法也几乎一样. 作用 @RequestHeade ...

  8. winform版的dota改键器

    从网上找的源码很不齐全,自己补充了一下,有兴趣的可以看看. 首先是建立一个hook类WFChangeKey using System; using System.Reflection; using S ...

  9. 在Windows Server 2008 R2 Server中,上传视频遇到的问题(二)

    上一篇  在Windows Server 2008 R2 Server中,上传视频遇到的问题(一)中遇到上传40M视频报404,然后修改配置文件节点: <httpRuntime targetFr ...

  10. css权重计算规则

    1.第一等:代表内联样式,如 style=" ",权值为1000: 2.第二等:代表ID选择器,如 #content,权值为0100: 3.第三等:代表类,伪类和属性选择器,如 . ...