win32 读写 ini 文件

如题:

#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
	int nStudentAge;  
	nStudentAge = GetPrivateProfileIntA("KEY", "KEY1_X", 20, ".\\camera.ini");   
	printf("%d\n", nStudentAge);
}

如题:GetPrivateProfileIntA(); 与 GetPrivateProfileInt();

GetPrivateProfileStringA(

    __in_opt LPCSTR lpAppName,
    __in_opt LPCSTR lpKeyName,
    __in_opt LPCSTR lpDefault,
    __out_ecount_part_opt(nSize, return + 1) LPSTR lpReturnedString,
    __in     DWORD nSize,
    __in_opt LPCSTR lpFileName

)


参数依次:小节、条目、读取失败的默认返回值、初始化文件

参数依次:小节、条目、读取失败的默认返回值、存储字符串、字符串长度、初始化文件


WINBASEAPI
BOOL
WINAPI
WritePrivateProfileStringA(
    __in_opt LPCSTR lpAppName,
    __in_opt LPCSTR lpKeyName,
    __in_opt LPCSTR lpString,
    __in_opt LPCSTR lpFileName
);


windows 最基础的,应该是不考虑空格、大小写之类的格式吧

猜你喜欢

转载自blog.csdn.net/u010477528/article/details/54016682