Win32 配置文件用法
#include “stdafx.h”
#include <Shlobj.h>
#include <Shlwapi.h>
#pragma comment(lib, “Shlwapi.lib”)
int _tmain()
{
TCHAR szPath[MAX_PATH];
if(S_OK==SHGetFolderPath(NULL,
CSIDL_PERSONAL|CSIDL_FLAG_CREATE,
NULL,
0,
szPath))
{
//PathAppend(szPath, TEXT(“New Doc.txt”));
//HANDLE hFile = CreateFile(szPath, …);
}
StrCat(szPath,_T(“\\hello.ini”));
//GetPrivateProfileSectionNames(szPath,MAX_PATH,);
//MessageBoxW(NULL,szPath,0,0);
OutputDebugString(szPath);
::WritePrivateProfileStringW(_T(“INFO”),_T(“NAME”),_T(“hello”),szPath);
::WritePrivateProfileStringW(_T(“MONEY”),_T(“COUNT”),_T(“10”),szPath);
TCHAR szBuff[1024];
GetPrivateProfileSectionNames(szBuff,MAX_PATH,szPath);
int i = 0;
do
{
if (szBuff[i])
{
OutputDebugString(szBuff+i);
while(szBuff[++i]);
}
} while (szBuff[++i]);
return 0 ;
}