#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"); }