본문 바로가기

Test Code/C++

[WinApi] Ini 파일 읽고 쓰기

/*

INI 파일은 Section, Key, Value 로 구성된다.

파일이 없으면 만들어진다.


쓰기 함수 : WritePrivateProfileString 

읽기 함수 : GetPrivateProfileString

*/


#include <iostream>

#include <windows.h>


using namespace std;


int main()

{

char szBuffer[256];

char szFileName[256] = "Config.ini";

char szSection[256] = "System";

char szKey[256] = "ServerIP";

// 쓰기

WritePrivateProfileString(

szSection, 

szKey,

"192.100.0.1",

szFileName);

// 읽기

GetPrivateProfileString(

szSection,

szKey,

"",

szBuffer,

256,

szFileName);

cout << szBuffer << endl;

return 0;

}



'Test Code > C++' 카테고리의 다른 글

[WinApi] 해당 경로의 파일 리스트 조회  (0) 2013.12.27
[WinApi] GetCurrentDirectory 현재 경로 가져오기  (0) 2013.12.27
[C++]배열 사이즈 구하기  (0) 2013.12.27
[STL] algorithm for_each 예제  (0) 2013.12.27
c++ time.h  (0) 2013.12.24