WritePrivateProfileSection 示例

#include <windows.h>

int main()
{
    //绝对路径
    char csPath[] = "C:\\Users\\Lenovo\\Desktop\\ConsoleApplication3\\Debug\\config.ini";
    char csBuffer[256];
    //创建节点  没有则创建文件
    bool ret = WritePrivateProfileSection("abc", "test=1", csPath);
    //1 ini 字段名 2 变量名 3变量值 4地址
    ret = WritePrivateProfileString("pen1", "name", "make", csPath);
    //查询  1 要找的字段名 2要找的key  3null  4返回存放缓冲区 5缓冲区大小 6路径
    GetPrivateProfileString("pen1", "name", NULL, csBuffer,sizeof(csBuffer), csPath);
    system("pause");
}

 

posted @ 2021-08-09 14:22  紅人  阅读(530)  评论(0编辑  收藏  举报